Binary integer decimal: Difference between revisions

Content deleted Content added
Comparing BID numbers: Not sure so leave out.
removed a sentence unrelated to BID from the LEDE and joined the remaining last two sentences
 
(64 intermediate revisions by 40 users not shown)
Line 1:
{{Use dmy dates|date=May 2019|cs1-dates=y}}
The draft [[IEEE 754r]] standard proposed two encoding formats for decimal floating point numbers, the formats are referred to in the standard as binary encoding and decimal encoding.<ref>{{cite web
{{floating-point}}
| title = DRAFT Standard for Floating Point Arithmetic P754
{{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}}
| date = 2006-10-04
The [[IEEE 754-2008]] standard includes decimal floating-point number formats in which the [[significand]] and the exponent (and the payloads of [[NaN]]s) can be encoded in two ways, referred to as '''binary encoding''' and ''decimal encoding''.<ref>{{cite web
| url = http://754r.ucbtest.org/drafts/archive/2006-10-04.pdf
| title = DRAFT Standard for Floating Point Arithmetic P754
| accessdate = 2007-07-01 }}</ref>. The binary encoding format is referred to by Intel<ref>
| date = 2006-10-04
| url = http://754r.ucbtest.org/drafts/archive/2006-10-04.pdf
|accessdate=2007-07-01
}}{{dead link|date=November 2016 |bot=InternetArchiveBot |fix-attempted=yes }}</ref>
<!-- Not sure why this next one is here? Proprietary/trade marks and propaganda articles not scientific, surely? Arith18 paper would be much better
| accessdate = 2007-07-01 }}</ref>. The binary encoding format is referred to by Intel<ref>
{{cite web
| title = IEEE 754R Decimal Floating-Point Arithmetic: Reliable and Efficient Implementation for Intel® Architecture Platforms
| publisher = Intel
| date = February 15, 2007-02-15
| url = http://www.intel.com/technology/itj/2007/v11i1/s2-decimal/1-sidebar.htm
| accessdate = 2007-07-01 }}
</ref> and others as Binary Integer Decimal (BID).
-->
==Format==
[[Image:BID_general_format.PNG|right|frame|The three fields of a binary integer decimal number]]
A BID number has three fields, the sign the exponent and the significand.
 
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), while in the '''binary integer decimal''' ('''BID''') encoding, it is encoded as a binary number.
If the top bits of the exponent are less than or equal binary 1110:
 
==Format==
''s'' = +1 (positive numbers) when the sign bit is 0
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 four 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):
''s'' = &minus;1 (negative numbers) when the sign bit is 1
 
* If the significand starts with <code>0mmm</code>, omitting the leading 0 bit lets the significand fit into 23 bits:
''e'' = ''exponent'' &minus; ''bias''
s 00eeeeee (0)mmm mmmmmmmmmm mmmmmmmmmm
s 01eeeeee (0)mmm mmmmmmmmmm mmmmmmmmmm
s 10eeeeee (0)mmm mmmmmmmmmm mmmmmmmmmm
* If the significand starts with <code>100m</code>, omitting the leading 100 bits lets the significand fit into 21 bits. The exponent is shifted over 2 bits, and a <code>11</code> bit pair shows that this form is being used:
s 1100eeeeee (100)m mmmmmmmmmm mmmmmmmmmm
s 1101eeeeee (100)m mmmmmmmmmm mmmmmmmmmm
s 1110eeeeee (100)m mmmmmmmmmm mmmmmmmmmm
* Infinity, quiet [[NaN]] and signaling NaN use encodings beginning with <code>s 1111</code>:
s 11110 xxxxxxxxxxxxxxxxxxxxxxxxxx
s 111110 xxxxxxxxxxxxxxxxxxxxxxxxx
s 111111 xxxxxxxxxxxxxxxxxxxxxxxxx
 
The bits shown in parentheses are ''implicit'': they are not included in the 32 bits of the Decimal32 encoding, but are implied by the two bits after the sign bit.
''m'' = ''significand''.
 
The Decimal64 and Decimal128 encodings have larger exponent and significand fields, but operate in a similar fashion.
The number has the value:
 
For the Decimal128 encoding, 113 bits of significand is actually enough to encode 34 decimal digits, and the second form is never actually required.
''v'' = ''s'' &times; 10''<sup>e</sup>'' &times; ''m''
 
The ''exponent'' and ''significand'' are stored as binary integers.
 
If the top five bits of the exponent field has the encoding 11110 binary, the number represents + or - infinity, the sign bit determines which. Nan is represented by the tops five bits of the exponent field being set to 11111.
 
==Cohort==
A decimal floating -point number can be encoded in several ways, the different ways represent different accuraciesprecisions, for example 100.0 could beis encoded as 1000*101000×10<sup>-1−1</sup>, while 100.00 could beis encoded 10000*10as 10000×10<sup>-2−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==
The proposed IEEEE754rIEEE 754r standard limits the range of numbers to a significand of the muchform smaller10<sup>n</sup>&minus;1, where n is the number of whole decimal digits range that can be representedstored byin the otherbits encodingavailable so describedthat bydecimal the standard,rounding [[Denselyis Packedeffected Decimal]]correctly.
{| class="wikitable" style="text-align:right"
 
{| class="wikitable"
|-
|
! item
! 32 bit
! 64 bit
! 128 bit
|-
|! Storage bits
| 32
| 64
| 128
|-
|! Trailing Significand bits
| 20
| 50
| 110
|-
|! Significand bits
| 23/24
| 53/54
| 113
|-
! Significand digits
| Combination bit
| 7
| 16
| 34
|-
|! Combination bitbits
| 11
| 13
| 17
|-
|! Exponent bits
| 8
| 10
| 14
|-
|! Bias
| 101
| 398
| 6176
|-
|! Standard emax
| 96
| 384
| 6144
|-
|! Standard emin
| 95−95
| 383−383
| 6143−6143
|}
 
==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 web|url=http://speleotrove.com/decimal/decperf.html|title = Decimal Library Performance - 1.01}}</ref>
 
==See Alsoalso==
 
* [[IEEE 754r754]]
==See Also==
[[IEEE 754r]]
 
==References==
{{reflist}}
<references />
 
==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]]