Hi, is there anyway (either with a forumula or a command) to get an output of the length of a number?

int(log(#)) +1. i believe its also one of those facts on the 83/84 homepage

Visit Calccrypto for info on crypto

KC2ZOF

Thanks, that worked perfectly. Could you please explain why that works?

this is probably a terrible explanation:

123 = 1 * 10^{2} + 2 * 10^{1} + 3*10^{0}

the highest power of 123 is 2, but that is the difference between the power and 0. however, 10^{0} counts as a decimal place too, so to get the total number of digits, you need to add 1

log_{10}N gets the highest power of any number in base 10, so as stated above, add 1 to get the number of digits

Visit Calccrypto for info on crypto

KC2ZOF

At every power of ten, you obtain a new digit.

10^{0} = 1

10^{1} = 10

10^{2} = 100

10^{3} = 1000

We need to find in between what two powers of 10 the number in question is. The number 123 is between 100 and 1000 (10^{2} and 10^{3}). log will tell you the lower bound, but as you can see the number of digits is 1 plus the power. Therefore `1+int(log(N`.

**NOTE**: This only works for positive integers. If a program has a chance of wielding negatives, be sure to use `1+int(log(abs(N` or else it will error.

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

The common logarithm asks to what power 10 should be raised to arrive at the input.

If the input is 100, the answer is "2."

If the input is a little more than 100, the answer is "a little more than 2."

If the input is a little less than 1000, the answer is "a little less than 3."

When the input is exactly 1000, the answer is exactly "3."

For every successive power of 10, the integer part of the result ticks up the next number.