Negative zero $



  • 3 months ago I left Verizon, as I consolidated phone plans with my fiance. Now every month I receive the following bill in my email:

    [img]http://dl.dropbox.com/u/6753359/Verizon.PNG[/img]



  • All these recent posts about negative or zero dollars outstanding accounts...  Is it really that fucking hard to put in the following logic:

    if (invoice.AccountBalance == 0)

      return;

    else

      SendInvoiceEmail(invoice);



  • But [code]0 != -0[/code] ... Apparently they are using floating point math for money. Awesome.



  • I'd expect no less from a company that doesn't know dollars from cents.



    Nothing wrong with invoices for $0 though. That way you have a record of not owing them anything. ($-0 on the other hand...)



  • @Xyro said:

    But <font face="Lucida Console" size="2">0 != -0</font> ... Apparently they are using floating point math for money. Awesome.

    Actually, 0 == -0. Although the real balance here is probably something like -0.0001, which is correctly rounded to -0.



  • @lolwtf said:

    I'd expect no less from a company that doesn't know dollars from cents.
    HAHA.  Such a ... funny ... call.


  • 🚽 Regular

    @Sutherlands said:

    HAHA.  Such a ... funny ... call.
     

    It's become a Christmas tradition for me: Watch A Christmas Story, Rudolph, Love Actually, and the vcents audio file complete with the nutcracker hold music.



  • Are you sure that $-0 isn't an emoticon?  Maybe it's the one for "I'm surprised and closing my eyes because a snake is slithering across my face".

    (Not sure how that relates to billing though.)

     



  • @RTapeLoadingError said:

    Are you sure that $-0 isn't an emoticon?  Maybe it's the one for "I'm surprised and closing my eyes because a snake is slithering across my face".

    (Not sure how that relates to billing though.)


    Maybe it's the emoticon for "eyes sewn shut".



  • @RTapeLoadingError said:

    Are you sure that $-0 isn't an emoticon?  Maybe it's the one for "I'm surprised and closing my eyes because a snake is slithering across my face".
     

    No no, it's the one for those horizontal-blinds sunglasses.




  • @dhromed said:

    @RTapeLoadingError said:

    Are you sure that $-0 isn't an emoticon?  Maybe it's the one for "I'm surprised and closing my eyes because a snake is slithering across my face".
     

    No no, it's the one for those horizontal-blinds sunglasses.


    If one of the glasses was vertical-blinded, you could use it to view 3D imagery.



  • @lolwtf said:

    I'd expect no less from a company that doesn't know dollars from cents.

    No, no, they know the difference, they just realize that .002 is a Magic Number where all units converge. God, don't they teach people anything in math class these days?



  • @lolwtf said:

    I'd expect no less from a company that doesn't know dollars from cents.



    Nothing wrong with invoices for $0 though. That way you have a record of not owing them anything. ($-0 on the other hand...)

    Yeah, I have no problem with getting a bill for $0 (although after 3 months of having a $0 bill that should stop). It's more the $-0 that makes me go wtf



  • @derula said:

    If one of the glasses was vertical-blinded, you could use it to view 3D imagery.

    interference

     

    You mean polarization?



  • Late to the party, but
    @Spectre said:

    @Xyro said:
    But <font face="Lucida Console" size="2">0 != -0</font> ... Apparently they are using floating point math for money. Awesome.

    Actually, 0 == -0. Although the real balance here is probably something like -0.0001, which is correctly rounded to -0.

    Mathematically, perhaps, but it's not math that's running the computer. 0 != -0 when it comes from a signed representation. Standard IEEE-${floating-point-standard-reference} floating point representation has a sign bit, as I'm sure you know, so 1 followed by 31 zeros is not logically equal to 32 zeros, even though they are mathematically equal.

    Now, assuming they're using floating points to represent money is just a fun assumption on my part. If they are at least halfway competent -- and we all know that's debatable -- they could be using some complex money type that also has a sign bit. Forgetting to specify -0 equal to 0 probably wouldn't be as bad as using floating point money in the first place, but either way it's silly x 10.


    For any further interested parties, here's a quick test in Java I wrote to make I'm not mistaken:

    
    import java.math.BigInteger;
    

    public class SignedZero {
    static public void main(String[] args) {

    	float zero = 0;
    	float nzero = Float.intBitsToFloat(BigInteger.ONE.shiftLeft(31).intValue());
    	// The literal "-0" is just interpreted as zero.
    	
    	println("Zero:          ", zero);  // 0.0
    	println("Negative zero: ", nzero); // -0.0
    	
    	int zeroBits  = Float.floatToRawIntBits(zero);
    	int nzeroBits = Float.floatToRawIntBits(nzero);
    	
    	println("Equal?      ", nzero == zero); // true!
    	println("Bits equal? ", nzeroBits == zeroBits); // false!
    	
    	println("Zero bits:          ", Integer.toBinaryString(zeroBits));  // 0
    	println("Negative zero bits: ", Integer.toBinaryString(nzeroBits)); // 10000000000000000000000000000000
    }
    
    static private void println(Object... msg) {
    	for (Object o : msg) System.out.print(o);
    	System.out.println();
    }
    

    }



  • @dhromed said:

    @derula said:

    If one of the glasses was vertical-blinded, you could use it to view 3D imagery.

    interference

     

    You mean polarization?

    [url=http://en.wikipedia.org/wiki/Parallax_barrier]Parallax barrier[/url], in fact.



  • Jesus Christ, could you let one solitary thread pass through without ruining all the humor in it? For once? Maybe?


  • ♿ (Parody)

    @blakeyrat said:

    Jesus Christ, could you let one solitary thread pass through without ruining all the humor in it? For once? Maybe?

    Where's the fun in that?



  • @Xyro said:

    Parallax barrier, in fact.
     

    ?

    Parallax barrier would require both glasses to have the same orientation.



  • @dhromed said:

    @Xyro said:

    Parallax barrier, in fact.
     

    ?

    Parallax barrier would require both glasses to have the same orientation.

    It's that barrier in front of the third level of Parallax. Fucking bitch to get through even if you're at full speed. (The one that unlocks after you've found the codes PLACE and JEWEL. OOPS SPOILERS TO A 1986 C-64 GAME!

    I think this extremely dull 7:00 AM meeting has melted my brain.



  • The IEEE 754 floating-point representation and one's complement integer representation both allow negative zero which differs from positive zero.

    One of my professors told a story about figuring out what his electric meter needed to read in order to generate a predetermined total due. He would pay for two billing periods so that when the electric company ran the billing process for the second period, his total due would be exactly negative zero. This would crash their mainframe. They repeatedly requested that he discontinue this practice which inspired him to continue until they stopped asking.



  • @Xyro said:

    But <font face="Lucida Console" size="2">0 != -0</font> ... Apparently they are using floating point math for money.

    @Spectre said:

    Actually, 0 == -0.

    @Xyro said:

    0 != -0 when it comes from a signed representation.

    @Xyro said:

    println("Equal? ", nzero == zero); // true!

    ...



  • @blakeyrat said:

    Jesus Christ, could you let one solitary thread pass through without ruining all the humor in it? For once? Maybe?

    [url]http://www.youtube.com/watch?v=v6BL6QvKljo[/url]





  • @dhromed said:

    @derula said:

    If one of the glasses was vertical-blinded, you could use it to view 3D imagery.

    interference

     

    You mean polarization?

    Yeah, I couldn't remember the term on the spot so I thought I'd write that instead, hoping to cause a flame war among some physics geeks. It sort of worked, I guess.



  • @derula said:

    hoping to cause a flame war among some physics geeks
     

    Goddamnit, you are such a stupid idiot.



  • @Xyro said:

    Apparently they are using floating point math for money. Awesome.

    Or one's complement. I'm not sure which would be the bigger WTF.


  • Trolleybus Mechanic

    @lolwtf said:

    Nothing wrong with invoices for $0 though. That way you have a record of not owing them anything. ($-0 on the other hand...)
     

    $-0 That means Verison owes him $0. He should demand a payout.



  • @Faxmachinen said:

    @Xyro said:
    Apparently they are using floating point math for money. Awesome.

    Or one's complement. I'm not sure which would be the bigger WTF.

    Or, they are using "-" as a decimal separator, and $-0 is just short for $0-00.



  • @derula said:

    @Faxmachinen said:
    @Xyro said:
    Apparently they are using floating point math for money. Awesome.

    Or one's complement. I'm not sure which would be the bigger WTF.

    Or, they are using "-" as a decimal separator, and $-0 is just short for $0-00.

    Maybe a rogue developer changed the [url=http://forums.thedailywtf.com/forums/p/24339/253315.aspx]const string strDollarSign[/url] to "$-".




    (PS, with my Java code test above, I totally forgot to show you the most important part. While [code]zero == nzero[/code], [code]Float.valueOf(zero).equals(Float.valueOf(nzero))[/code] returns [code]false[/code]. So if they were using the boxed objects instead of the primitives (or equivalent in whatever language it was using if possible), then zero would not equal negative zero. SORRY TO KEEP HARPING ON THIS, BUT I'M BORED AND HATE JOKES.)


Log in to reply