truncate or round?
hi i have a number coming from a scale
35.2200001
I hope to record this particular number into a coll rounded down to 35.22
so i tried
( round 0.01)
(expr int($f1+($f1>0.)-0.05)
(sprintf .2f)
I even converted the number to an audio signal and used (trunc~)
each of these allowed me to view at 2 decimal places, but when sending into a coll it always records in the coll at 35.2200001. along with all my other numbers.
Is there a way to round up or down a number and record the rounded result into the coll?
thanks
What about x 100. -> int -> x 100. ?
Oops! Make the last object / 100.
and if you want to round a float to the nearest integer instead of truncate it, you can take the round object in the same manner bill suggested:
*100. -> round -> /100.
BTW "round 0.01 " is working on my system, which is even more simpler.
works even with coll
i guess that 35.22 simply does not exist: there is only 35.2200001
so everytime you convert that number first to a symbol and then back to a number, it becomes longer again.
thanks Bill yes i tried x 100. /100. it was still the same.
Thanks Ben i shall try your patch when i am on my max machine tomorrow..
in the mean time , i am just storing the longer numbers and I am just rounding when I view the data.
i've realise i don't actually need to store it rounded up or down it just looked a mess and It was just so puzzling!
yes Roman i tried converting with tosymbol and fromsymbol as well, same result.
I shall still try your patch later on Ben, thanks!!
Great patch Ben
That works fine. It all goes into the coll perfectly.
It looks so simple, but i just could not get it to work.
nice one ! : p