C# log base 10 and rounding up to nearest power of 10?

Posted by Tom on Stack Overflow See other posts from Stack Overflow or by Tom
Published on 2010-05-31T00:13:36Z Indexed on 2010/05/31 0:22 UTC
Read the original article Hit count: 139

Filed under:

Hi, if i have a number between 100 and 1000 i want to get the value 3 because 10^3 = 1000. Likewise, if i had a number between 10 and 100 i would want to get the value 2, because 10^2 is 100.

Incase you're wondering, its to do with calculating a probability and i always need to divide through by 10^value, to keep the probability between 0 and 1. For example if i calculate 9256, i need to divide through by 10^4, so that i get a probability of 0.92

I'm not sure how to do the rounding up and how to do the base 10, could someone please help?

© Stack Overflow or respective owner

Related posts about c#