8
1
Find the original challenge here
Challenge
Given an integer, Z
in the range -2^31 < Z < 2^31
, output the number of digits in that number (in base 10).
Rules
You must not use any string functions (in the case of overloading, you must not pass a string into functions which act as both string and integer functions). You are not allowed to store the number as a string.
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. Number will never be a decimal.
Zero is effectively a leading zero, so it can have zero or one digit.
Examples
Input > Output
-45 > 2
1254 > 4
107638538 > 9
-20000 > 5
0 > 0 or 1
-18 > 2
Winning
Shortest code in bytes wins.
I assume no array functions either? – Cyoce – 2017-05-19T16:45:04.387
@Cyoce Yes, no array functions – Beta Decay – 2017-05-19T17:04:41.840
So if a language only accepts input as a string, it's invalid for this challenge, right? – Engineer Toast – 2017-05-19T19:24:15.420
@EngineerToast Yes, very much so – Beta Decay – 2017-05-19T19:33:21.547
I'm removing the restricted source tag because while this is a restriction it is not a real source restriction in that it is not computer tractable. – Post Rock Garf Hunter – 2017-05-19T21:50:43.623