Understanding how many digits within a number

Aug 24, 2013 at 5:41am

Understanding how many digits within a number

Hi

I am trying to work out how large a number is determined by how many indivdual numbers are in a numbers.

For example, I know that 100 has three digits. And 10 has two digits. I am having difficulty understanding how to receive this information to bang further information

J

#259746
Aug 24, 2013 at 6:23am

try [expr int(log10($i1))+1]

basically log10 converted to integer, and then + 1.

…there are probably cheaper ways of doing it, but hey.

#259756
Aug 24, 2013 at 7:58am

thank you

#259839
Aug 25, 2013 at 7:54am

[itoa] and then some list manipulation is probably a tad cheaper, CPU-wise, but the log() formula works.

Back in the days when I was using a BASIC interpreter on a Commodore C64, it actually made a difference, but that was a long time ago.

#259947

You must be logged in to reply to this topic.