Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #4396

Re: About using assertion

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news-out.readnews.com!news-xxxfer.readnews.com!panix!not-for-mail
From tmcd@tmcd-p4-linux.austin.tx.us (Tim McDaniel)
Newsgroups comp.lang.java.programmer
Subject Re: About using assertion
Date Sat, 21 May 2011 18:37:23 -0500
Organization Tim McDaniel's home IBM-PC clone running Linux
Lines 31
Message-ID <juula8-jc3.ln1@tmcd-linux-p4.austin.tx.us> (permalink)
References <f1e4cc83-8596-4e53-bed7-34a5209fe8c4@k3g2000prl.googlegroups.com> <92r0e9F6lvU1@mid.individual.net> <sjmea8-067.ln1@tmcd-linux-p4.austin.tx.us> <se-dnUMuGp0Fj0jQnZ2dnUVZ_o-dnZ2d@earthlink.com>
Reply-To tmcd@panix.com
NNTP-Posting-Host 99-50-234-96.lightspeed.austtx.sbcglobal.net
X-Trace reader1.panix.com 1306022882 15150 99.50.234.96 (22 May 2011 00:08:02 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Sun, 22 May 2011 00:08:02 +0000 (UTC)
X-Newsreader trn 4.0-test76 (Apr 2, 2001)
Originator tmcd@tmcd-p4-linux.austin.tx.us (Tim McDaniel)
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4396

Show key headers only | View raw


In article <se-dnUMuGp0Fj0jQnZ2dnUVZ_o-dnZ2d@earthlink.com>,
Patricia Shanahan  <pats@acm.org> wrote:
>Negative zero is a strange beast. As far as I can tell, it exists
>mainly to produce negative infinity when it is used as a divisor. For
>example, it is equal to zero for comparison purposes.

Hm, I thought it didn't, but the authoritative-looking but old
<http://www.concentric.net/~ttwang/tech/javafloat.htm> says otherwise.

However, Float/Double apparently acts differently from float/double:

    Comparing two Java "Float" objects can have different semantics
    than comparing two Java "float" values. Recall the "float" class
    is a Java primitive class, while java.lang.Float is a subclass of
    "Object".

    A "NaN" value is not equal to itself. However, a "NaN" Java
    "Float" object is equal to itself. The semantic is defined this
    way, because otherwise "NaN" Java "Float" objects cannot be
    retrieved from a hash table.

    (new Float(0.0 / 0.0)).equals(new Float(0.0 / 0.0))  ->  true

    For the class java.lang.Float, objects are ordered from lowest to
    highest: -Infinity, negative numbers, -0.0, 0.0, positive numbers,
    Infinity, NaN. "java.lang.Double" objects are identically ordered.

    (new Float(0.0)).equals(new Float(-0.0))  ->  false

-- 
Tim McDaniel; Reply-To: tmcd@panix.com

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: About using assertion tmcd@tmcd-p4-linux.austin.tx.us (Tim McDaniel) - 2011-05-19 00:32 -0500
  Re: About using assertion Michal Kleczek <kleku75@gmail.com> - 2011-05-19 08:34 +0200
    Re: About using assertion Lew <noone@lewscanon.com> - 2011-05-19 08:46 -0400
      Re: About using assertion Michal Kleczek <kleku75@gmail.com> - 2011-05-19 15:16 +0200
        Re: About using assertion Lew <noone@lewscanon.com> - 2011-05-19 09:38 -0400
          Re: About using assertion Robert Klemme <shortcutter@googlemail.com> - 2011-05-19 07:41 -0700
            Re: About using assertion Lew <noone@lewscanon.com> - 2011-05-19 11:00 -0400
  Re: About using assertion Patricia Shanahan <pats@acm.org> - 2011-05-19 05:52 -0700
    Re: About using assertion tmcd@tmcd-p4-linux.austin.tx.us (Tim McDaniel) - 2011-05-21 18:37 -0500
      Re: About using assertion Patricia Shanahan <pats@acm.org> - 2011-05-21 19:00 -0700
      Re: About using assertion Lew <noone@lewscanon.com> - 2011-05-22 01:19 -0400

csiph-web