Step math function

Posted by ekapek on Stack Overflow See other posts from Stack Overflow or by ekapek
Published on 2010-05-25T19:43:46Z Indexed on 2010/05/25 19:51 UTC
Read the original article Hit count: 255

Filed under:
|

Hi

I need function which returns:

  • for any number from range => result

    [0.001,0.01) => 0.01

    [0.01,0.1) => 0.1

    [0.1,1) => 1

    [1,10) => 10

    [10,100) => 100

    etc.

My first idea was to use if, but this the worst way. Is there a simple solution?

© Stack Overflow or respective owner

Related posts about math

Related posts about rounding