From bug-octave-request at bevo dot che dot wisc dot edu Wed Jan 22 16:16:11 2003 Subject: Re: Trivial 0ctave bug From: "Richard E. Borcherds" To: jwe at bevo dot che dot wisc dot edu CC: bug-octave at bevo dot che dot wisc dot edu Date: Wed, 22 Jan 2003 16:10:48 -0600 >| Octave version 2.1.34 incorrectly gives __realmin__ the value >| 2^-1022 on machines that support IEEE 754 64 bit arithmetic. >| The correct value should be 2^-1074 >| because IEEE 754 has "subnormal"numbers. The documentation >| for help __realmin__ needs fixing in the same way. (So does the numerical >| analysis textbook I am using...) > >I'm not sure that this is a bug in Octave. The variable realmin is >set in src/data.cc using the C macro DBL_MIN. What do you suggest as >a portable fix? > >BTW, Matlab also seems to behave this way, so any fix is likely to >break compatibility. If you want to keep matlab compatibility, the simplest fix would be to change the "help realmin" command: instead of claiming that realmin returns the smallest positive representable floating point number, state that it ought to do this, but sometimes only gives the smallest positive representable *normalized* floating point number due to buggy compilers. Alternatively you could tell matlab about this problem so that they fix it too! If you prefer to get the right answer, maybe something like this: realmin=DBL_MIN; while(0.0 < realmin/2.0 && realmin/2.0 < realmin) realmin=realmin/2.0; realmin should now be the smallest positive double, even if the compiler has the wrong (positive) value of DBL_MIN. (Sorry, I cant offhand find the source files for octave on this computer, so I'm sort of guessing that DBL_MIN is a constant and realmin is a double.) In IEEE754 the result of halving the smallest positive real realmin is defined to be +0, but with some forms of rounding used on older computers you could get realmin/2.=realmin, and you might also get some sort of underflow error. I've no idea what you would get on an old cray... Richard Borcherds. ------------------------------------------------------------- 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 -------------------------------------------------------------