Re: Bug in math.e?

new topic     » goto parent     » topic index » view thread      » older message » newer message
Anthill said...

Round seems to give me a problem. Is there a way to get the expected output?

 
atom a 
a = 183.4126   
puts(1,to_string(round(a)))      -- got 183, expected 183 
puts(1,to_string(round(a,10)))   -- got 183.400000000000006, expected 183.4 
puts(1,to_string(round(a,100)))  -- got 183.409999999999997, expected 183.42 
puts(1,to_string(round(a,1000))) -- got 183.413000000000011, expected 183.413 

The output looks correct to me. The differences look like the rounding errors inherent in using floating point numbers.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu