https://wcipeg.com/wiki/index.php?title=Long_double&feed=atom&action=historyLong double - Revision history2024-03-28T21:49:08ZRevision history for this page on the wikiMediaWiki 1.25.2https://wcipeg.com/wiki/index.php?title=Long_double&diff=1810&oldid=prevAlex: /* Properties */2014-08-20T22:22:56Z<p><span dir="auto"><span class="autocomment">Properties</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 22:22, 20 August 2014</td>
</tr><tr><td colspan="2" class="diff-lineno" id="L9" >Line 9:</td>
<td colspan="2" class="diff-lineno">Line 9:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The range of a <code>long double</code> can be checked in C using <code><float.h></code> and C++ using <code>std::numeric_limits</code>. This 80-bit format typically has a range of roughly 1.9E-4932 ... 1.1E+4932 and holds 19-20 significant digits.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The range of a <code>long double</code> can be checked in C using <code><float.h></code> and C++ using <code>std::numeric_limits</code>. This 80-bit format typically has a range of roughly 1.9E-4932 ... 1.1E+4932 and holds 19-20 significant digits.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Even though the <code>long double</code> may be stored using 96 or even 128 bits (you can check the number of bits using <code><del class="diffchange diffchange-inline">4</del>*sizeof(long double)</code>), it still only has 80 bits of precision. The extra padding bits are to help modern architectures align to 8 or 16 bit boundaries. In GCC, the compiler switches <code>-m96bit-long-double</code> and <code>-m128bit-long-double</code> may be used to control the storage size of a <code>long double</code>, without of course, changing its precision in any way.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Even though the <code>long double</code> may be stored using 96 or even 128 bits (you can check the number of bits using <code><ins class="diffchange diffchange-inline">8</ins>*sizeof(long double)</code>), it still only has 80 bits of precision. The extra padding bits are to help modern architectures align to 8 or 16 bit boundaries. In GCC, the compiler switches <code>-m96bit-long-double</code> and <code>-m128bit-long-double</code> may be used to control the storage size of a <code>long double</code>, without of course, changing its precision in any way.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>==Usage==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>==Usage==</div></td></tr>
</table>Alexhttps://wcipeg.com/wiki/index.php?title=Long_double&diff=1809&oldid=prevAlex: Added useful info2014-08-20T22:22:35Z<p>Added useful info</p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 22:22, 20 August 2014</td>
</tr><tr><td colspan="2" class="diff-lineno" id="L3" >Line 3:</td>
<td colspan="2" class="diff-lineno">Line 3:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>On many architectures, <code>long double</code> is identical to <code>double</code>, since <code>double</code> is usually a [[IEEE 754|binary64]] and many architectures do not support a longer floating-point data type. On Intel x86 machines, however, <code>long double</code> is often a 80-bit ''extended precision'' format that originated with the Intel 8087 numeric coprocessor. This format is almost exactly analogous to the [[IEEE 754]] formats, except that its significand does not carry an implicit leading 1. It consists of a sign bit, a 15-bit biased exponent field, and a 64-bit significand field. Because the x86 processors are little-endian, when this kind of number is stored in memory, the lowest-address 8 bytes are used for the significand, the next byte is used for the least significant 8 bits of the exponent, and the last byte contains the sign bit as the most significant bit, followed by the most significant 7 bits of the exponent.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>On many architectures, <code>long double</code> is identical to <code>double</code>, since <code>double</code> is usually a [[IEEE 754|binary64]] and many architectures do not support a longer floating-point data type. On Intel x86 machines, however, <code>long double</code> is often a 80-bit ''extended precision'' format that originated with the Intel 8087 numeric coprocessor. This format is almost exactly analogous to the [[IEEE 754]] formats, except that its significand does not carry an implicit leading 1. It consists of a sign bit, a 15-bit biased exponent field, and a 64-bit significand field. Because the x86 processors are little-endian, when this kind of number is stored in memory, the lowest-address 8 bytes are used for the significand, the next byte is used for the least significant 8 bits of the exponent, and the last byte contains the sign bit as the most significant bit, followed by the most significant 7 bits of the exponent.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">In Pascal, the corresponding data types are <code>Extended</code> (Free/Borland/GNU Pascal) and also <code>LongReal</code> (GNU Pascal), which also hold 80 bits of information.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">==Properties==</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">The range of a <code>long double</code> can be checked in C using <code><float.h></code> and C++ using <code>std::numeric_limits</code>. This 80-bit format typically has a range of roughly 1.9E-4932 ... 1.1E+4932 and holds 19-20 significant digits.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">Even though the <code>long double</code> may be stored using 96 or even 128 bits (you can check the number of bits using <code>4*sizeof(long double)</code>), it still only has 80 bits of precision. The extra padding bits are to help modern architectures align to 8 or 16 bit boundaries. In GCC, the compiler switches <code>-m96bit-long-double</code> and <code>-m128bit-long-double</code> may be used to control the storage size of a <code>long double</code>, without of course, changing its precision in any way.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">==Usage==</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">To <code>scanf</code> or <code>printf</code> a <code>long double</code>, one should use the format specifier <code>%Lf</code> (<code>%llf</code> also works sometimes, although it is nonstandard).</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">A well-known bug on Windows is that MinGW uses the Microsoft C run-time libraries which do not have good support for the <code>long double</code> type. Attempts to print it will result in weird behaviour. As a workaround, a <code>long double</code> may be cast to <code>double</code> before being printed.</ins></div></td></tr>
</table>Alexhttps://wcipeg.com/wiki/index.php?title=Long_double&diff=1589&oldid=prevBrian: Created page with "{{DISPLAYTITLE:long double}} <code>long double</code> is a primitive floating-point data type in C (and subsequently C++) that is required by the standard to be at least as long ..."2012-02-13T04:05:31Z<p>Created page with "{{DISPLAYTITLE:long double}} <code>long double</code> is a primitive floating-point data type in C (and subsequently C++) that is required by the standard to be at least as long ..."</p>
<p><b>New page</b></p><div>{{DISPLAYTITLE:long double}}<br />
<code>long double</code> is a primitive floating-point data type in C (and subsequently C++) that is required by the standard to be at least as long as a <code>double</code>. That is, the values it can represent must be a superset of the values that a <code>double</code> can represent.<br />
<br />
On many architectures, <code>long double</code> is identical to <code>double</code>, since <code>double</code> is usually a [[IEEE 754|binary64]] and many architectures do not support a longer floating-point data type. On Intel x86 machines, however, <code>long double</code> is often a 80-bit ''extended precision'' format that originated with the Intel 8087 numeric coprocessor. This format is almost exactly analogous to the [[IEEE 754]] formats, except that its significand does not carry an implicit leading 1. It consists of a sign bit, a 15-bit biased exponent field, and a 64-bit significand field. Because the x86 processors are little-endian, when this kind of number is stored in memory, the lowest-address 8 bytes are used for the significand, the next byte is used for the least significant 8 bits of the exponent, and the last byte contains the sign bit as the most significant bit, followed by the most significant 7 bits of the exponent.</div>Brian