Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Negative zero from a multiplication by a zero?

by ysth (Canon)
on Jun 12, 2009 at 16:11 UTC ( #771013=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Negative zero from a multiplication by a zero?
in thread Negative zero from a multiplication by a zero?

Ideally, IOK would not get turned on for a negative zero, which should fix this.

If you were desperate, you could compile a perl with PERL_PRESERVE_IVUV turned off.


Comment on Re^3: Negative zero from a multiplication by a zero?
Re^4: Negative zero from a multiplication by a zero?
by syphilis (Canon) on Jun 13, 2009 at 02:15 UTC
    If you were desperate, you could compile a perl with PERL_PRESERVE_IVUV turned off.

    Hey ... that works!! (No, I'm not desperate - just anal :-)

    Any arithmetic operation on IV's now seems to turn them into NV's so (-2 * 0) reports -0 even though the original operands are IV's.
    (2 * -0) reports 0, but that's to be expected given the underlying events.
    (2 * -0.0) does report -0, again as expected.

    One thing I did find while building this perl was that 'dmake test' reported 2 failures in the Devel::Peek tests - all other tests passed. I suspect those 2 Devel::Peek tests might be overlooking the possibility of NO_PERL_PRESERVE_IVUV being defined. I'll check that out properly later today, and submit a bug report.

    Cheers,
    Rob

      Somebody should just fix the bad floating point implementation / standard. Having -1.2 * 0 be -0 rather seriously misses the point of "negative zero" and brings it into play in places where it has no business and is just a royal pain with no benefit.

      If you want to detect the sign of your underflow, you should bother to check before multiplying by a negative value or you should get a floating point implementation that distinguishes "zero" from "positive zero" (but most floating point implementations don't do that because "negative zero" was partly motivated by having a spare bit handy and there isn't as handy of a bit to make "positive zero" out of).

      Surely we need "negative NaN" as much as "negative zero". We must distinguish +Inf * 0 from +Inf * -0, surely. At least, it makes just as much sense as having "negative zero" for one underflow case (but not having a special value for "positive underflow", much less another for "underflow of indeterminate sign").

      - tye        

        Surely we need "negative NaN" as much as "negative zero".

        Sssshhh ... you'll give 'em ideas.
        The standard that I find really absurd is NaN ** 0 being defined as 1. The logic seems to be that since *all* numbers raised to the power 0 are 1, then NaN ** 0 should also be 1. (Those who create these standards are apparently unaware of the fact that a NaN is not a number.)

        Cheers,
        Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://771013]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-12-26 03:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls