Double is a 64-bit data type representing the double precision floating-point format, in IEEE 754-1985 called double, in IEEE 754-2008 64-bit base 2 format is officially referred to as binary64. Due to normalization the true significand includes an implicit leading one bit unless the exponent is stored with all bits zeros or ones which are reserved for Denormal numbers. Thus only 52 bits of the significand are stored but the total precision is 53 bits (≈15.955 decimal digits). Exponent bias is 0x3FF (1023).

Recent x86 and x86-64 processors provide x87, and SSE2 double precision floating point instruction sets. Since SSE2 is not obligatory for x86-32, 32-bit operating systems rely on x87. x86-64 64-bit operating systems may use the faster SSE2 instructions, but so far only 64-bit compiler for 64-bit Windows emit those instructions implicitly for double precision floating point operations ^{[1]} . SSE2 instructions can be mixed with x87 and are explicitly available through (inline) Assembly or intrinsics of various C-Compilers.

Integer to Double Conversion

X87

To convert a signed or unsigned integer to float, two x87 instructions are needed, FILD and FSTP working on the x87 floating point stack ^{[2]} .

FILD
The FILD instruction converts a signed-integer in memory to double-extended-precision (10 bytes) format and pushes the value onto the x87 register stack. The value can be a 16-bit, 32-bit, or 64- bit integer value. Signed values from memory can always be represented exactly in x87 registers without rounding.

FSTP
The FSTP instruction pops the x87 stack after copying the value. The instruction FSTP ST(0) is the same as popping the stack with no data transfer. If the specified destination is a single-precision (4 bytes) or double-precision (8 bytes) memory location, the instruction converts the value to the appropriate precision format. It does this by rounding the significand of the source value as specified by the rounding mode determined by the RC field of the x87 control word and then converting to the format of destination. It also converts the exponent to the width and bias of the destination format.

SSE2

^{[3]}^{[4]} CVTDQ2PD
Converts two packed 32-bit signed integer values in the low-order 64 bits of an XMM register or a 64-bit memory location to two packed double-precision floating-point values and writes the converted values in another XMM register.

CVTPI2PD
Converts two packed 32-bit signed integer values in an MMX register or a 64-bit memory location to two double-precision floating-point values and writes the converted values in an XMM register.

CVTSI2SD
Converts a 32-bit or 64-bit signed integer value in a general-purpose register or memory location to a double-precision floating-point value and writes the converted value in the low-order 64 bits of an XMM register. The high-order 64 bits in the destination XMM register are not modified.

Integer to Double conversion can be used as base 2 logarithm of a power of two value of a 64-bit signed or unsigned integer, which might be used as 64-bit bitscan, as mentioned in Double conversion of LS1B and Double conversion.

## Table of Contents

Home * Programming * Data * DoubleDoubleis a 64-bit data type representing the double precision floating-point format, in IEEE 754-1985 called double, in IEEE 754-2008 64-bit base 2 format is officially referred to as binary64. Due to normalization the true significand includes an implicit leading one bit unless the exponent is stored with all bits zeros or ones which are reserved for Denormal numbers. Thus only 52 bits of the significand are stored but the total precision is 53 bits (≈15.955 decimal digits). Exponent bias is 0x3FF (1023).## x86 Instruction Sets

Recent x86 and x86-64 processors provide x87, and SSE2 double precision floating point instruction sets. Since SSE2 is not obligatory for x86-32, 32-bit operating systems rely on x87. x86-64 64-bit operating systems may use the faster SSE2 instructions, but so far only 64-bit compiler for 64-bit Windows emit those instructions implicitly for double precision floating point operations^{[1]}. SSE2 instructions can be mixed with x87 and are explicitly available through (inline) Assembly or intrinsics of various C-Compilers.## Integer to Double Conversion

## X87

To convert a signed or unsigned integer to float, two x87 instructions are needed, FILD and FSTP working on the x87 floating point stack^{[2]}.FILDThe FILD instruction converts a signed-integer in memory to double-extended-precision (10 bytes) format and pushes the value onto the x87 register stack. The value can be a 16-bit, 32-bit, or 64- bit integer value. Signed values from memory can always be represented exactly in x87 registers without rounding.

FSTPThe FSTP instruction pops the x87 stack after copying the value. The instruction FSTP ST(0) is the same as popping the stack with no data transfer. If the specified destination is a single-precision (4 bytes) or double-precision (8 bytes) memory location, the instruction converts the value to the appropriate precision format. It does this by rounding the significand of the source value as specified by the rounding mode determined by the RC field of the x87 control word and then converting to the format of destination. It also converts the exponent to the width and bias of the destination format.

## SSE2

^{[3]}^{[4]}CVTDQ2PDConverts two packed 32-bit signed integer values in the low-order 64 bits of an XMM register or a 64-bit memory location to two packed double-precision floating-point values and writes the converted values in another XMM register.

CVTPI2PDConverts two packed 32-bit signed integer values in an MMX register or a 64-bit memory location to two double-precision floating-point values and writes the converted values in an XMM register.

CVTSI2SDConverts a 32-bit or 64-bit signed integer value in a general-purpose register or memory location to a double-precision floating-point value and writes the converted value in the low-order 64 bits of an XMM register. The high-order 64 bits in the destination XMM register are not modified.

## BitScan Purpose

Integer to Double conversion can be used as base 2 logarithm of a power of two value of a 64-bit signed or unsigned integer, which might be used as 64-bit bitscan, as mentioned in Double conversion of LS1B and Double conversion.## See also

## Publications

1991).What every computer scientist should know about floating-point arithmetic. ACM Computing Surveys, reprint as pdf## Forum Posts

## External Links

## References

## What links here?

Up one Level