Dear Airkon:
The first step would be to find the scale of the number. That would be done
by taking the log 10 of the number and truncating that to an integer.
Next, raise 10 to that power and integer divide your value by that, then
multiply it back.
Wouldn't that give you the proper result? Perhaps not for negative numbers,
but I didn't see your specification for those. You'd best try it.
The log function is an inefficient way of doing this in terms of CPU, so if
you are doing a large number of these at a time, some other approach would
be good. Perhaps a case statement would be useful, or a comparable
if/then/else.
Tom Ellison
Airkon said:
I think you misunderstood me. I meant like writing a function to always
truncate it to the first digit, not a function for 2 different kinds of
decimals.
Say, if I have a new number 13.12445 and I call
mytruncatefunction(13.12445), it will return me a 10. The function just
removes all the values behind until the first non zero digit.
Sorry if I didn make any sense earlier.
Ofer said:
For the first two numbers - 0.05
int([MyNumber]*100)/100
For the next two numbers - 5000
int([MyNumber]/1000)*1000
--
\\// Live Long and Prosper \\//
BS"D
:
I hope to truncate some values for calculations but cant seem to do it
right.
Example:
0.05666 -> 0.05
0.05444 -> 0.05
5678 -> 5000
5432 -> 5000
Is there any simple way to code this function? Thanks in advance.