Forums > MaxMSP

Understanding how many digits within a number


Joe
August 24, 2013 | 5:41 am

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


August 24, 2013 | 6:23 am

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

basically log10 converted to integer, and then + 1.

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



Joe
August 24, 2013 | 7:58 am

thank you


August 25, 2013 | 7:54 am

[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.


Viewing 4 posts - 1 through 4 (of 4 total)