strange results.. ?

P

psy

[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!
 
Y

yermej

[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#Accuracy_problems
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Strange output from arange() 2
Ruby can't subtract ? 24
Really basic problem 4
strange behaviour if exploding parameters 3
dup and clone 4
Help with my responsive home page 2
Chatbot 0
Strange bug in irb1.9 7

Staff online

Members online

Forum statistics

Threads
473,991
Messages
2,570,217
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top