Posted: Sun Apr 28, 2002 1:02 pm
Restored from previous forum. Originally posted by tinman.
Hi,
Would it be possible to add a command for setting the way floating point numbers are rounded when you transfer them to integers? Every language I have ever used simply cuts off the fraction, which I find most useful (of course, I can see that it could be handy to have it rounded to the nearest integer, but I have never needed that case personally).
I know you can use Round(x,0) but isn't this slower than simply x.w=y.f (since it has to go to the hassle of calling a command, whereas the assignment can be done inline).
Something like this perhaps:
RoundMode -1 ; always round down
RoundMose 0 ; round to nearest integer - default setting
RoundMode 1 ; always round up
I've also noticed that a float with a value of .5 always rounds down, whereas mathematically you would round this up. I'm willing to accept that this is is a problem of floating point accuracy though.
Thanks.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
Hi,
Would it be possible to add a command for setting the way floating point numbers are rounded when you transfer them to integers? Every language I have ever used simply cuts off the fraction, which I find most useful (of course, I can see that it could be handy to have it rounded to the nearest integer, but I have never needed that case personally).
I know you can use Round(x,0) but isn't this slower than simply x.w=y.f (since it has to go to the hassle of calling a command, whereas the assignment can be done inline).
Something like this perhaps:
RoundMode -1 ; always round down
RoundMose 0 ; round to nearest integer - default setting
RoundMode 1 ; always round up
I've also noticed that a float with a value of .5 always rounds down, whereas mathematically you would round this up. I'm willing to accept that this is is a problem of floating point accuracy though.
Thanks.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.