octave-maintainers
[Top][All Lists]
Advanced

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

Re: please dont fix this... Matlab vs Octave Integer Division


From: John W. Eaton
Subject: Re: please dont fix this... Matlab vs Octave Integer Division
Date: Thu, 15 Mar 2007 09:40:47 -0400

On 13-Mar-2007, Benjamin Lindner wrote:

| > | So Matlab does integer division incorrectly... I thought I should let 
| > | you know. I prefer your implementation with the correct answer.
| > | 2/3 should equal 0 but Matlab will tell you it's 1.
| > 
| > Matlab also rounds to the nearest values for things like int32 (0.9).
| > I think this that having Octave behave differently from Matlab for
| > something like this is not good, so I checked in the following patch.
| > Note that the /= operator was already rounding.
| 
| Yes, but is it really necessary to give up correct and IMO useful 
| behaviour just because Matlab implements it differently?

In this case, I think yes, because otherwise code that depends on the
semantics of Matlab's integer division and conversion will silently
produce incorrect results.

| Forgive my asking, but why sacrifice for the sake of compatibility?
| Losing correct behaviour of integer artihmetic will remove one

Neither 2/3 = 0 or 2/3 = 1 is correct mathematically, so I don't see
that you are losing much.

As I said, if you want your preferred integer operations in Octave, I
think you need another set of data types.  I see no other option than
to use Matlab semantics for the types defined by Matlab.

jwe



reply via email to

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