|
From: | Przemek Klosowski |
Subject: | Re: find command sometimes doesn't work in script |
Date: | Thu, 12 Nov 2009 14:44:41 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.4pre) Gecko/20091014 Fedora/3.0-2.8.b4.fc11 Thunderbird/3.0b4 |
On 11/12/2009 06:43 AM, Jaroslav Hajek wrote:
On Thu, Nov 12, 2009 at 12:33 PM, Lidia Bressan <address@hidden Just for curiosity, the equality you said works: octave:119> 1 + 21 * 0.05 == 2.05 ans = 1 octave:120> 1 == 1 ans = 1 Oh yes. Sorry, that was a nonsense. Of course this works. But it wouldn't work in C++ (which is what Octave does internally).
Are you saying that the expression "1+21*.05" gives a different result in Octave and C++? I thought that the difference results from the fact that 1+21*.05 and the corresponding element of [1:.05:3] are calculated by different methods--although I am not sure what is the method used by the range expression.
It is instructive to display the binary representation ('format hex') for several ways of calculating 2.05:
internal repr. Octave expression 4000666666666666 2.05 <-- straight number 4000666666666666 1+21*0.05 <-- simple calculation 4006666666666667 [1:.05:3](37) <-- corresp. number from the range 4006666666666666 [3:-.05:1](5) <-- just for fun, reverse range4006666666666662 1+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05 4006666666666668 .05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+.05+1
From these data, I take it that 1:.05:3 is not simply computed by successive accumulation like in the fifth expression above.
[Prev in Thread] | Current Thread | [Next in Thread] |