help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is this a numerical problem?


From: Lukas Reichlin
Subject: Is this a numerical problem?
Date: Thu, 19 Aug 2010 10:39:45 +0200

Dear Octave community

I'm using Octave 3.2.4 from MacPorts on MacOSX 10.6.4 running on an Intel Core 
2 Duo. I noticed a behaviour which seems strange to me. Does someone have a 
good explanation for the results below? 

octave:60> a = (10 * rem (-12/5, 1))
a = -4.00000000000000  # a < -4
octave:61> fix (a)
ans = -3  # I'm expecting -4
octave:62> a + 4
ans =  8.88178419700125e-16  # I'm expecting something negative


# While this is working as expected
octave:63> b = -4.001
b = -4.00100000000000
octave:64> fix (b)
ans = -4
octave:65> b + 4
ans = -0.00100000000000033


The same with R2009a:

>> a = (10 * rem (-12/5, 1))

a =

   -4.0000

>> fix (a)

ans =

    -3

>> a+4

ans =

   8.8818e-16

>> b = -4.001

b =

   -4.0010

>> fix (b)

ans =

    -4

>> b + 4

ans =

   -0.0010

>> 


Best Regards,
Lukas


reply via email to

[Prev in Thread] Current Thread [Next in Thread]