This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Doyle3694's profile picture

Getting number of digits

Started by Doyle3694, 23 October 2012 - 02:39 PM
Doyle3694 #1
Posted 23 October 2012 - 04:39 PM
Hey guys, just wondering, is there a way to get the number of digits in a number, so for example, I enter 5678 and use it in this function so it will return 4. short of, ofcourse, writing and getting CursorPos
faubiguy #2
Posted 23 October 2012 - 05:14 PM
You can use string.len on numbers.
string.len(5678) -- Returns 4
PixelToast #3
Posted 23 October 2012 - 05:16 PM
or just use the # operator

val=5678
return #val
faubiguy #4
Posted 23 October 2012 - 05:21 PM
or just use the # operator

val=5678
return #val

Doesn't work. I just tested it. Attempt to get length of number
Doyle3694 #5
Posted 23 October 2012 - 05:25 PM
OK, thanks