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

H

Henry

Does JavaScript have a mechanism to provide the equivalent of
Java's Double.doubleToLongBits() and the reverse operation
Double.longBitsToDouble?
<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.
 
D

Dr J R Stockton

In comp.lang.javascript message <169621bd-7a0d-4b75-97c3-c3afdc0d743e@f4
7g2000hsd.googlegroups.com>, Wed, 6 Feb 2008 00:22:29,
(e-mail address removed) posted:
Does JavaScript have a mechanism to provide the equivalent of Java's
Double.doubleToLongBits() and the reverse operation
Double.longBitsToDouble?

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.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.demon.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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top