53.

prev next contents
d2l

convert double to long integer

Jasmin Syntax
     d2l 
Stack

Before

After
double-word1
long-word1
double-word2
long-word2
...
...
Description

Pops a two-word double precision floating point number off of the operand stack, converts it into a 64-bit long integer, and pushes the resulting two-word long onto the stack.

Rounding is done using IEEE 754 round-to-nearest mode. The fractional part is lost by rounding towards zero, so (long)-3.14 becomes -3.

If the original double value is NaN, the result is 0. If the value is too large to be represented as an integer, or if it is positive infinity, the result is the largest possible long integer Long.MAX_VALUE. If the value is too small (i.e. a negative value of large magnitude, or negative infinity) then the result is the most negative long integer Long.MIN_VALUE.

In some implementations, this may be coded using the C casting mechanism, e.g.

 void d2l(double d, int &l_high, int &l_low) {     l_low = (unsigned int)d; l_high = (unsigned int)(d / 2**32); } 
where l_low and l_high are respectively the least significant and most significant 32-bit words of the long.

Bytecode

Type

Description
u1
d2l opcode = 0x8F (143)
See Also

d2i, d2f


prev next contents
Java Virtual Machine, by Jon Meyer and Troy Downing, O'Reilly Associates


Java Virtual Machine
Java Virtual Machine (Java Series)
ISBN: 1565921941
EAN: 2147483647
Year: 1996
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net