Double

toc
 * Home * Programming * Data * Double**


 * 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).

=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. SSE2 instructions can be mixed with x87 and are explicitly available through (inline) Assembly or intrinsics of various C-Compilers.
 * [[image:618px-IEEE_754_Double_Floating_Point_Format.svg.png width="640" link="http://en.wikipedia.org/wiki/Double_precision_floating-point_format"]] ||
 * [|Double precision floating-point format] ||

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.

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.
 * FILD**

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.
 * FSTP**

SSE2
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.
 * CVTDQ2PD**
 * Mnemonic: CVTDQ2PD xmm1, xmm2/mem64
 * Intrinsic: [|_mm_cvtepi32_pd]

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.
 * CVTPI2PD**
 * Mnemonic: CVTPI2PD xmm, mmx/mem64
 * Intrinsic: [|_mm_cvtpi32_pd]

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.
 * CVTSI2SD**
 * Mnemonic: CVTSI2SD xmm, reg/mem32 (reg/mem64)
 * Intrinsic: [|_mm_cvtsi32_sd]

=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=
 * Quad Word
 * SSE
 * SSE2
 * Float

=Publications=
 * David Goldberg (**1991**). //What every computer scientist should know about floating-point arithmetic//. ACM Computing Surveys, reprint as [|pdf]

=Forum Posts=
 * [|Bitboards using 2 DOUBLE's ?] by Carey, CCC, June 02, 2009 » Bitboards

=External Links=
 * [|Floating point from Wikipedia]
 * [|Double precision floating-point format]
 * [|Extended precision]
 * [|Quadruple precision floating-point format]
 * [|Survey of Floating-Point Formats] by [|Robert Munafo]
 * [|About Floating Point Arithmetic] from Johanns Blog

=References= =What links here?= include page="Double" component="backlinks" limit="40"
 * Up one Level**