[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

strange results.. ?

psy

3/13/2008 10:59:00 PM

[Note: parts of this message were removed to make it a legal post.]


Hello people,

Here I get some strange (for me) results :


irb(main):012:0> 0.4 - 0.3 - 0.1
=> 2.77555756156289e-17

irb(main):013:0> 0.5 - 0.4 - 0.1
=> -2.77555756156289e-17

irb(main):017:0> 0.2 + 0.7 - 0.9
=> -1.11022302462516e-16

Can somebody explain what happens here or point me some place where i
can get information for this topic?
Thanks in advance!

1 Answer

yermej

3/13/2008 11:40:00 PM

0

On Mar 13, 5:59 pm, psy <p...@matt-schwarz.com> wrote:
> [Note: parts of this message were removed to make it a legal post.]
>
> Hello people,
>
> Here I get some strange (for me) results :
>
> irb(main):012:0> 0.4 - 0.3 - 0.1
> => 2.77555756156289e-17
>
> irb(main):013:0> 0.5 - 0.4 - 0.1
> => -2.77555756156289e-17
>
> irb(main):017:0> 0.2 + 0.7 - 0.9
> => -1.11022302462516e-16
>
> Can somebody explain what happens here or point me some place where i
> can get information for this topic?
> Thanks in advance!

http://en.wikipedia.org/wiki/Floating_point#Accurac...