+0 and -0 and SQRT in Fortran77

G.W.Bultman uunet!dgw.rws.nl!bultman
Wed Jan 20 10:30:52 PST 1993


Hi,

A small Fortran problem of moderately general interest. 

On our HP9000, a single precision real can represent +0 and -0
( 00 00 00 00  and  80 00 00 00 ).

For all purposes, such as adding etc. this does not create any problems,
but when the SQRT is taken, -0 generates a NaN.

This, of course, is rather unfortunate, as we have a program which 
does several divisions of the type x/y, where x can be 0.0 and y can be
-1.0, thus generating a -0. 

Can anyone offer a solution or other helpful comments?

Thanks,
Gert.

Please reply to me directly: bultmanadgw.rws.nl
===============================================

--

    o                                                                o   
  / | \    Gert Bultman <bultmanadgw.rws.nl>   Koningskade 4       / | \  
 o--o--o   Tidal Waters Division               2596 AA The Hague  o--o--o 
  \ | /    Rijkswaterstaat                     The Netherlands     \ | /  
    o                                                                o    




More information about the Numeric-interest mailing list