Re: Probably for David Cuny

new topic     » goto parent     » topic index » view thread      » older message » newer message

Terry Moriarty writes:
> while temp != 0 do
>    my_string = ((((temp/10)-(floor(temp/10)))*10)+48) & my_string
>    temp = floor(temp/10)
> end while

Yes, this is what I suspected. You fell into the
very common trap of requiring floating-point
results to be perfectly accurate. The characters in
my_string will not necessarily all be perfect integers.

For example, (61/10 - floor(61/10)) * 10 will probably not
be *exactly* 1. It might be something like 0.99999999999999
which rounds down (later on) to 0. You could round
your digits, with something like digit = floor(digit+0.5)
to make them exact integers (or just use sprint()).

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu