Binary integer decimal: Difference between revisions

Content deleted Content added
CE
removed a sentence unrelated to BID from the LEDE and joined the remaining last two sentences
 
(21 intermediate revisions by 12 users not shown)
Line 1:
{{Use dmy dates|date=May 2019|cs1-dates=y}}
{{floating-point}}
{{Cleanup|reason=This article more describes DPD encoding and IEEE 754 encoding in general, rather than BID encoding which it should acc. it's title.|date=December 2024}}
The [[IEEE 754-2008]] standard includes an encoding format for decimal floating-point pointnumber numbersformats in which the [[significand]] and the exponent (and the payloads of [[NaN]]s) can be encoded in two ways, referred to in the draft as '''binary encoding''' and ''decimal encoding''.<ref>{{cite web
|title=DRAFT Standard for Floating Point Arithmetic P754
|date=2006-10-04
Line 17 ⟶ 19:
-->
 
Both formats break a number down into a sign bit ''s'', an exponent ''q'' (between ''q''<sub>min</sub> and ''q''<sub>max</sub>), and a ''p''-digit significand ''c'' (between 0 and 10<sup>''p''</sup>−1). The value encoded is (&minus;1)<sup>''s''</sup>×10<sup>''q''</sup>×''c''. In both formats the range of possible values is identical, but they differ in how the significand ''c'' is represented. In the decimal encoding, it is encoded as a series of ''p'' decimal digits (using the [[densely packed decimal]] (DPD) encoding). This makes conversion to decimal form efficient, but requires a specialized decimal [[Arithmetic logic unit|ALU]] to process. while Inin the '''binary integer decimal''' ('''BID''') encoding, it is encoded as a binary number.
 
==Format==
Using the fact that 2<sup>10</sup> = 1024 is only slightly more than 10<sup>3</sup> = 1000, 3''n''-digit decimal numbers can be efficiently packed into 10''n'' binary bits. However, the IEEE formats have significands of 3''n''+1 digits, which would generally require 10''n''+4 binary bits to represent.
 
This would not be efficient, because only 10 of the 16 possible values of the additional 4four bits are needed. A more efficient encoding can be designed using the fact that the exponent range is of the form 3×2<sup>''k''</sup>, so the exponent never starts with <code>11</code>. Using the Decimal32 encoding (with a significand of 3*2+1 decimal digits) as an example (<code>e</code> stands for exponent, <code>m</code> for mantissa, i.e. significand):
 
* If the significand starts with <code>0mmm</code>, omitting the leading 0 bit lets the significand fit into 23 bits:
Line 44 ⟶ 46:
 
==Cohort==
A decimal floating -point number can be encoded in several ways, the different ways represent different precisions, for example 100.0 is encoded as 1000×10<sup>−1</sup>, while 100.00 is encoded as 10000×10<sup>−2</sup>. The set of possible encodings of the same numerical value is called a ''cohort'' in the standard. If the result of a calculation is inexact the largest amount of significant data is preserved by selecting the cohort member with the largest integer that can be stored in the significand along with the required exponent.
 
==Range==
Line 102 ⟶ 104:
 
==Performance==
A binary encoding is inherently less efficient for conversions to or from decimal-encoded data, such as strings ([[ASCII]], [[Unicode]], etc.) and [[Binary-coded decimal|BCD]]. A binary encoding is therefore best chosen only when the data are binary rather than decimal. IBM has published some unverified performance data,.<ref>{{Cite availableweb|url=http://speleotrove.com/decimal/decperf.html|title at= Decimal Library Performance - 1.01}}</ref>
[http://speleotrove.com/decimal/decperf.html], however as both packages are available as open-source these figures could not be verified independently.
 
==See also==
Line 110 ⟶ 111:
==References==
{{reflist}}
 
==Further reading==
* {{cite web |title=The Decimal Floating-Point Standard |author-first=John J. G. |author-last=Savard |date=2018 |orig-year=2007 |work=quadibloc |url=http://www.quadibloc.com/comp/cp020302.htm |access-date=2018-07-16 |url-status=live |archive-url=https://web.archive.org/web/20180703002322/http://www.quadibloc.com/comp/cp020302.htm |archive-date=2018-07-03}}
 
[[Category:Computer arithmetic]]
[[Category:IEEE standards]]