From bug-octave-request at bevo dot che dot wisc dot edu Wed Jan 29 21:42:19 2003 Subject: Re: Trivial 0ctave bug From: "John W. Eaton" To: Mirek Kwasniak Cc: "John W. Eaton" , "Richard E. Borcherds" , bug-octave@bevo.che.wisc.edu Date: Wed, 29 Jan 2003 21:42:01 -0600 On 23-Jan-2003, Mirek Kwasniak wrote: | On Wed, Jan 22, 2003 at 02:15:30PM -0600, John W. Eaton wrote: | > BTW, Matlab also seems to behave this way, so any fix is likely to | > break compatibility. | | Yes we have compatibility, in fuctions rem, mod remainder can be greater | then divisor :) | | In a message: | http://groups.google.pl/groups?selm=eeb79a1.-1%40WebX.raydaftYaTP | | In MATLAB version 6.1 and 6.5, | | | >> rem(3.0782817340933185e+099,1e7) | ans = | 4.856672230564323e+083 | >> mod(3.0782817340933185e+099,1e7) | ans = | 4.856672230564323e+083 | | | $ octave2.1 | GNU Octave, version 2.1.43 (i386-pc-linux-gnu). | octave2.1:1> rem(3.0782817340933185e+099,1e7) | ans = 4.8567e+83 Rather than try to "fix" this, I've introduced yet another function, fmod, which simply calls the C library funciton fmod. FWIW, with that function I get the following result for your crazy numbers: octave:1> fmod (3.0782817340933185e+099, 1e7) ans = 7011968 jwe ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------