# How long is my number?

## Challenge

Given an integer $$\Q\$$ in the range $$\-2^{100} ≤ Q ≤ 2^{100}\$$, output the number of digits in that number (in base 10).

## Rules

Yes, you may take the number as a string and find its length.

All mathematical functions are allowed.

You may take input in any base, but the output must be the length of the number in base 10.

Do not count the minus sign for negative numbers. The number will never have a decimal point.

Zero can either have one or zero digits.

Assume the input will always be a valid integer.

## Examples

Input > Output

-45 > 2
12548026 > 8
33107638153846291829 > 20
-20000 > 5
0 > 1 or 0


## Winning

Shortest code in bytes wins.

# Braingolf, 2 bytes

dl


### Explaination:

dl
Implicit input from command-line args to stack
d   Pop last item from stack, split it into digits, and push each digit to the stack
l  Push length of stack to the end of the stack
Implicit output of last item on stack


# Brain-Flak, 48 + 3 ( -a) = 51 bytes

({}[((((()()()()())){}{})){}{}]){(<><>)}{}([]<>)


Try it online!

# C#, 28 bytes

s=>s.Replace("-","").Length;


# C, 71 38 bytes

• -33 bytes FelipeNardiBatista

Try Online

f(char*t){return*t?(*t>'-')+f(t+1):0;}

• why don't you just return the number? May 18, 2017 at 10:57
• golfed to 38 bytes May 18, 2017 at 11:05
• @FelipeNardiBatista changed now, thx May 18, 2017 at 11:19
• 35 bytes
– c--
Jul 20, 2022 at 14:48

# Swift, 138 bytes

You would think there would be an easier way to do this.

import Foundation;var d:(String)->Int={return $0.trimmingCharacters(in:CharacterSet(charactersIn:"0123456789").inverted).characters.count}  You can try it here Un-golfed: import Foundation // Import the Foundation module var d:(String)->Int={ // Create a closure that takes in a String and returns an Int return // Return the following$0.trimmingCharacters(in:  // Removes all characters in the following CharacterSet

CharacterSet(charactersIn:"0123456789").inverted // Create a CharacterSet with all characters that are not digits

).characters.count // Get the length of the resulting String
}


# Axiom, 23 Bytes

f(x)==#(abs(x)::String)


# Desmos, 31 bytes

g=abs(a)
f(a)=floor(log(g+0^g))


Try it on Desmos!

# Batch, 101 bytes

@set/pi=
@set o=-1&if %i:~,1%==- set o=-2
:l
@set/ao+=1&if %i%. neq . set i=%i:~,-1%&goto:l
@echo %o%


### 89 bytes

@set/pi=
@if %i% lss 0 set/ai=-%i%
:l
@set/ao+=1&if %i% gtr 9 set/ai/=10&goto:l
@echo %o%


Only works for 32-bit numbers.

# MathGolf, 2 bytes

±£


Input as integers.

Try it online.

I'm actually surprised builtin £ works on integers. I was expecting I would need an explicit cast, since that's the case with a lot of MathGolf's builtins.

Explanation:

±   # Get the absolute value of the (implicit) input-integer
£  # Pop and get the length of this integer
# (after which the entire stack is output implicitly as result)


# Japt, 2 bytes

ìl


Try it

ìl     :Implicit input of integer
ì      :Convert to digit array
l     :Length