>>Hi everyone,
>>
>>I'd like to convert numbers to the following:
>>
>>5->5
>>52->50
>>333->300
>>4567->5000
>>1234567->1000000, e.g. to the round number.
>>
>>What would be the simplest algorithm for this?
>
>?ROUND(x, -INT(LOG10(x)))
>
>For negative numbers, slightly more complicated:
>
>?ROUND(x, -INT(LOG10(ABS(x))))
>
>Works for numbers not between -1 and 1... for them, then, it would need a +1 decimal more.
This should be it
function xRound(x)
return iif(empty(x), 0, sign(x) * round(abs(x), -int(log10(abs(x))) ) )
endfunc
Gregory