help-octave
[Top][All Lists]
Advanced

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

Re: Numeric issue


From: Marco Atzeri
Subject: Re: Numeric issue
Date: Fri, 04 Jul 2014 16:33:14 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0


On 04/07/2014 11:46, JokerOne wrote:
Hi community,

I using Octave for quite a while now, however, apparently, I am not aware of
some numeric issues going on, which is where I like to ask you for help:

Basically, I noticed, that in the following dummy code, the results appear
strange to me:

clear all;
format long;

a   = [1.1:1.1:100];
a(50)                     % expected to be == 55
b   = 50*1.1;          % expected to be == 55

octave:7> 50*1.1
ans =  55.000


((a(50)-b) == 0)     % is 1
((a(50)-55) == 0)    % is 0 (!?)

this check is always questionable on any numerical operation,
due to rounding precision.
On my system:

octave:10> a(50)-55
ans =    7.1054e-15

ceil(a(50))              % expected to be == 55, but results in 56 ??
ceil(b)                    % same as above ??
ceil(55)                   % == 55, as expected

for the reason above the ceiling is 56....

Regards
Marco



reply via email to

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