Any equivalent to Java's Double.doubleToLongBits()?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chad_walters@yahoo.com

    Any equivalent to Java's Double.doubleToLongBits()?

    Does JavaScript have a mechanism to provide the equivalent of Java's
    Double.doubleTo LongBits() and the reverse operation
    Double.longBits ToDouble?

    http://java.sun.com/j2se/1.4.2/docs/...ongBits(double)

    Thanks in advance for any help.

    Chad
  • Henry

    #2
    Re: Any equivalent to Java's Double.doubleTo LongBits()?

    On Feb 6, 8:22 am, chad_walt...@ya hoo.com wrote:
    Does JavaScript have a mechanism to provide the equivalent of
    Java's Double.doubleTo LongBits() and the reverse operation
    Double.longBits ToDouble?
    <snip>

    No such facility exists in javascript, and as javascript only has one
    number type and it is an IEEE double precision floating point number
    the limit of numerically representable integers is 53 bits. So the bit
    pattern of an IEEE double precision floating point number cannot be
    represented as a (single) numeric integer value in javascript.

    Comment

    • Dr J R Stockton

      #3
      Re: Any equivalent to Java's Double.doubleTo LongBits()?

      In comp.lang.javas cript message <169621bd-7a0d-4b75-97c3-c3afdc0d743e@f4
      7g2000hsd.googl egroups.com>, Wed, 6 Feb 2008 00:22:29,
      chad_walters@ya hoo.com posted:
      >Does JavaScript have a mechanism to provide the equivalent of Java's
      >Double.doubleT oLongBits() and the reverse operation
      >Double.longBit sToDouble?
      >
      >http://java.sun.com/j2se/1.4.2/docs/...html#doubleToL
      >ongBits(double )

      Not intrinsically, whatever those operations mat be - and you could have
      given a better explanation.

      However, one can code conversion of a JavaScript Number (IEEE Double)
      to/from a bit string representing a Double (and the same for one
      representing a Single).

      See <URL:http://www.merlyn.demo n.co.uk/js-misc0.htm- works in AFAIK
      all browsers, but best read in MS IE.

      It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

      --
      (c) John Stockton, nr London UK. ?@merlyn.demon. co.uk IE6 IE7 FF2 Op9 Sf3
      news:comp.lang. javascript FAQ <URL:http://www.jibbering.c om/faq/index.html>.
      <URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
      <URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.

      Comment

      Working...