tags:

views:

99

answers:

1
+3  Q: 

Step math function

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?

+6  A: 
10^(floor(log(x) + 1))
BlueRaja - Danny Pflughoeft