Decimal32 floating-point format

In computing, decimal32 is a decimal floating-point computer numbering format that occupies 4 bytes (32 bits) in computer memory.

Purpose and use

[edit]

Like the binary16 and binary32 formats, decimal32 uses less space than the actually most common format binary64.

Range and precision

[edit]

decimal32 supports 'normal' values, which can have 7 digit precision from ±1.000000×10^−95 up to ±9.999999×10^+96, plus 'subnormal' values with ramp-down relative precision down to ±1.×10^−101 (one digit), signed zeros, signed infinities and NaN (Not a Number). The encoding is somewhat complex, see below.

The binary format with the same bit-size, binary32, has an approximate range from subnormal-minimum ±1×10^−45 over normal-minimum with full 24-bit precision: ±1.1754944×10^−38 to maximum ±3.4028235×10^38.

Encoding of decimal32 values

[edit]

decimal32 values are encoded in a 'not normalized' near to 'scientific format', with combining some bits of the exponent with the leading bits of the significand in a 'combination field'.

Generic encoding
Sign Combination Trailing significand bits
1 bit 11 bits 20 bits
s mmmmmmmmmmm tttttttttttttttttttt

Besides the special cases infinities and NaNs there are four points relevant to understand the encoding of decimal32.

  • BID vs. DPD encoding, binary integer decimal using a positive integer value for the significand, software centric and designed by Intel, vs. densely packed decimal encoding for all except the first digit of the significand, hardware centric and promoted by IBM(r), differences see below. Both alternatives provide exactly the same range of representable numbers: up to 7 digits of significand and 3 × 26 = 192 possible exponent values. IEEE 754 allows these two different encodings, without a concept to denote which is used, for instance in a situation where decimal32 values are communicated between systems.
  • In contrast to the binary formats, the significands of decimal formats are not normalized (the leading digits are allowed to be 0), and thus most values with less than 7 significant digits have multiple possible representations. 1000000 × 10−2=100000 × 10−1=10000 × 100=1000 × 101 all have the value 10000. These sets of representations for a same value are called cohorts, the different members can be used to denote how many digits of the value are known precisely.
  • The encodings combine two bits of the exponent with the leading 3 to 4 bits of the significand in a 'combination field', different for 'big' vs. 'small' significands. That enables bigger precision and range, in trade-off that some simple functions like sort and compare, very frequently used in coding, do not work on the bit pattern but require computations to extract exponent and significand and then try to obtain an exponent aligned representation. This effort is partly balanced by saving the effort for normalization, but contributes to the slower performance of the decimal formats. Beware: BID and DPD use different bits of the combination field for that, see below.
  • Different understanding of significand as integer vs. fraction, and acc. different bias to apply for the exponent (for decimal32 what is stored in bits can be decoded as base to the power of 'stored value for the exponent minus bias of 95' times significand understood as d0 . d−1 d−2 d−3 d−4 d−5 d−6 (note: radix dot after first digit, significand fractional), or base to the power of 'stored value for the exponent minus bias of 101' times significand understood as d6 d5 d4 d3 d2 d1 d0 (note: no radix dot, significand integral),

both produce the same result [2019 version[1] of IEEE 754 in clause 3.3, page 18]. Both applies to BID as well as DPD encoding. For decimal formats the second view is more common, while for binary formats the first, the biases are different for each format.)

In all cases for decimal32, the value represented is

(−1)sign × 10exponent−101 × significand, with the significand understood as positive integer.

Alternatively it can be understood as (−1)sign × 10exponent−95 × significand with the significand digits understood as d0 . d−1 d−2 d−3 d−4 d−5 d−6, note the radix dot making it a fraction.

For ±Infinity, besides the sign bit, all the remaining bits are ignored (i.e., both the exponent and significand fields have no effect). For NaNs the sign bit has no meaning in the standard, and is ignored. Therefore, signed and unsigned NaNs are equivalent, even though some programs will show NaNs as signed. The bit m5 determines whether the NaN is quiet (0) or signaling (1). The bits of the significand are the NaN's payload and can hold user defined data (e.g., to distinguish how NaNs were generated). Like for normal significands, the payload of NaNs can be either in BID or DPD encoding.

Be aware that the bit numbering used in the tables for e.g. m10 … m0 is in opposite direction than that used in the document for the IEEE 754 standard G0 … G10.

BID encoding
Combination field Exponent Significand Description
m10 m9 m8 m7 m6 m5 m4 m3 m2 m1 m0
combination field not! starting with '11', bits ab = 00, 01 or 10
a b c d m m m m e f g abcdmmmm (0)efgtttttttttttttttttttt Finite number with significand < 8388608, fits into 23 bits.
combination field starting with '11', but not 1111, bits ab = 11, bits cd = 00, 01 or 10
1 1 c d m m m m e f g cdmmmmef 100gtttttttttttttttttttt Finite number with significand > 8388607, needs 24 bits.
combination field starting with '1111', bits abcd = 1111
1 1 1 1 0 ±Infinity
1 1 1 1 1 0 quiet NaN
1 1 1 1 1 1 signaling NaN (with payload in significand)

The resulting 'raw' exponent is a 8 bit binary integer where the leading bits are not '11', thus values 0 ... 10111111b = 0 ... 191d, appr. bias is to be subtracted. The resulting significand could be a positive binary integer of 24 bits up to 1001 1111111111 1111111111b = 10485759d, but values above 107 − 1 = 9999999 = 98967F16 = 1001100010010110011111112 are 'illegal' and have to be treated as zeroes. To obtain the individual decimal digits the significand has to be divided by 10 repeatedly.

DPD encoding
Combination field Exponent Significand Description
m10 m9 m8 m7 m6 m5 m4 m3 m2 m1 m0
combination field not! starting with '11', bits ab = 00, 01 or 10
a b c d e m m m m m m abmmmmmm (0)cde tttttttttt tttttttttt Finite number with small first digit of significand (0 … 7).
combination field starting with '11', but not 1111, bits ab = 11, bits cd = 00, 01 or 10
1 1 c d e m m m m m m cdmmmmmm 100e tttttttttt tttttttttt Finite number with big first digit of significand (8 or 9).
combination field starting with '1111', bits abcd = 1111
1 1 1 1 0 ±Infinity
1 1 1 1 1 0 quiet NaN
1 1 1 1 1 1 signaling NaN (with payload in significand)

The resulting 'raw' exponent is a 8 bit binary integer where the leading bits are not '11', thus values 0 ... 10111111b = 0 ... 191d, appr. bias is to be subtracted. The significand's leading decimal digit forms from the (0)cde or 100e bits as binary integer. The subsequent digits are encoded in the 10 bit 'declet' fields 'tttttttttt' according the DPD rules (see below). The full decimal significand is then obtained by concatenating the leading and trailing decimal digits.

The 10-bit DPD to 3-digit BCD transcoding for the declets is given by the following table. b9 … b0 are the bits of the DPD, and d2 … d0 are the three BCD digits. Be aware that the bit numbering used here for e.g. b9 … b0 is in opposite direction than that used in the document for the IEEE 754 standard b0 … b9, add. the decimal digits are numbered 0-base here while in opposite direction and 1-based in the IEEE 754 paper. The bits on white background are not counting for the value, but signal how to understand / shift the other bits. The concept is to denote which digits are small (0 … 7) and encoded in three bits, and which are not, then calculated from a prefix of '100', and one bit specifying if 8 or 9.

Densely packed decimal encoding rules[2]
DPD encoded value Decimal digits
Code space
(1024 states)
b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 d2 d1 d0 Values encoded Description Occurrences
(1000 states)
50.0%
(512 states)
a b c d e f 0 g h i 0abc 0def 0ghi (0–7) (0–7) (0–7) 3 small digits 51.2%
(512 states)
37.5%
(384 states)
a b c d e f 1 0 0 i 0abc 0def 100i (0–7) (0–7) (8–9) 2 small digits,
1 large digit
38.4%
(384 states)
a b c g h f 1 0 1 i 0abc 100f 0ghi (0–7) (8–9) (0–7)
g h c d e f 1 1 0 i 100c 0def 0ghi (8–9) (0–7) (0–7)
9.375%
(96 states)
g h c 0 0 f 1 1 1 i 100c 100f 0ghi (8–9) (8–9) (0–7) 1 small digit,
2 large digits
9.6%
(96 states)
d e c 0 1 f 1 1 1 i 100c 0def 100i (8–9) (0–7) (8–9)
a b c 1 0 f 1 1 1 i 0abc 100f 100i (0–7) (8–9) (8–9)
3.125%
(32 states, 8 used)
x x c 1 1 f 1 1 1 i 100c 100f 100i (8–9) (8–9) (8–9) 3 large digits,
b9, b8: don't care
0.8%
(8 states)
Representation of every number from 0 to 999
Representation Bits Value
0 0000000000 0
1 0000000001 1
2 0000000010 2
3 0000000011 3
4 0000000100 4
5 0000000101 5
6 0000000110 6
7 0000000111 7
8 0000001000 8
9 0000001001 9
16 0000010000 10
17 0000010001 11
18 0000010010 12
19 0000010011 13
20 0000010100 14
21 0000010101 15
22 0000010110 16
23 0000010111 17
24 0000011000 18
25 0000011001 19
32 0000100000 20
33 0000100001 21
34 0000100010 22
35 0000100011 23
36 0000100100 24
37 0000100101 25
38 0000100110 26
39 0000100111 27
40 0000101000 28
41 0000101001 29
48 0000110000 30
49 0000110001 31
50 0000110010 32
51 0000110011 33
52 0000110100 34
53 0000110101 35
54 0000110110 36
55 0000110111 37
56 0000111000 38
57 0000111001 39
64 0001000000 40
65 0001000001 41
66 0001000010 42
67 0001000011 43
68 0001000100 44
69 0001000101 45
70 0001000110 46
71 0001000111 47
72 0001001000 48
73 0001001001 49
80 0001010000 50
81 0001010001 51
82 0001010010 52
83 0001010011 53
84 0001010100 54
85 0001010101 55
86 0001010110 56
87 0001010111 57
88 0001011000 58
89 0001011001 59
96 0001100000 60
97 0001100001 61
98 0001100010 62
99 0001100011 63
100 0001100100 64
101 0001100101 65
102 0001100110 66
103 0001100111 67
104 0001101000 68
105 0001101001 69
112 0001110000 70
113 0001110001 71
114 0001110010 72
115 0001110011 73
116 0001110100 74
117 0001110101 75
118 0001110110 76
119 0001110111 77
120 0001111000 78
121 0001111001 79
10 0000001010 80
11 0000001011 81
42 0000101010 82
43 0000101011 83
74 0001001010 84
75 0001001011 85
106 0001101010 86
107 0001101011 87
46 0000101110 88
47 0000101111 89
26 0000011010 90
27 0000011011 91
58 0000111010 92
59 0000111011 93
90 0001011010 94
91 0001011011 95
122 0001111010 96
123 0001111011 97
62 0000111110 98
63 0000111111 99
128 0010000000 100
129 0010000001 101
130 0010000010 102
131 0010000011 103
132 0010000100 104
133 0010000101 105
134 0010000110 106
135 0010000111 107
136 0010001000 108
137 0010001001 109
144 0010010000 110
145 0010010001 111
146 0010010010 112
147 0010010011 113
148 0010010100 114
149 0010010101 115
150 0010010110 116
151 0010010111 117
152 0010011000 118
153 0010011001 119
160 0010100000 120
161 0010100001 121
162 0010100010 122
163 0010100011 123
164 0010100100 124
165 0010100101 125
166 0010100110 126
167 0010100111 127
168 0010101000 128
169 0010101001 129
176 0010110000 130
177 0010110001 131
178 0010110010 132
179 0010110011 133
180 0010110100 134
181 0010110101 135
182 0010110110 136
183 0010110111 137
184 0010111000 138
185 0010111001 139
192 0011000000 140
193 0011000001 141
194 0011000010 142
195 0011000011 143
196 0011000100 144
197 0011000101 145
198 0011000110 146
199 0011000111 147
200 0011001000 148
201 0011001001 149
208 0011010000 150
209 0011010001 151
210 0011010010 152
211 0011010011 153
212 0011010100 154
213 0011010101 155
214 0011010110 156
215 0011010111 157
216 0011011000 158
217 0011011001 159
224 0011100000 160
225 0011100001 161
226 0011100010 162
227 0011100011 163
228 0011100100 164
229 0011100101 165
230 0011100110 166
231 0011100111 167
232 0011101000 168
233 0011101001 169
240 0011110000 170
241 0011110001 171
242 0011110010 172
243 0011110011 173
244 0011110100 174
245 0011110101 175
246 0011110110 176
247 0011110111 177
248 0011111000 178
249 0011111001 179
138 0010001010 180
139 0010001011 181
170 0010101010 182
171 0010101011 183
202 0011001010 184
203 0011001011 185
234 0011101010 186
235 0011101011 187
174 0010101110 188
175 0010101111 189
154 0010011010 190
155 0010011011 191
186 0010111010 192
187 0010111011 193
218 0011011010 194
219 0011011011 195
250 0011111010 196
251 0011111011 197
190 0010111110 198
191 0010111111 199
256 0100000000 200
257 0100000001 201
258 0100000010 202
259 0100000011 203
260 0100000100 204
261 0100000101 205
262 0100000110 206
263 0100000111 207
264 0100001000 208
265 0100001001 209
272 0100010000 210
273 0100010001 211
274 0100010010 212
275 0100010011 213
276 0100010100 214
277 0100010101 215
278 0100010110 216
279 0100010111 217
280 0100011000 218
281 0100011001 219
288 0100100000 220
289 0100100001 221
290 0100100010 222
291 0100100011 223
292 0100100100 224
293 0100100101 225
294 0100100110 226
295 0100100111 227
296 0100101000 228
297 0100101001 229
304 0100110000 230
305 0100110001 231
306 0100110010 232
307 0100110011 233
308 0100110100 234
309 0100110101 235
310 0100110110 236
311 0100110111 237
312 0100111000 238
313 0100111001 239
320 0101000000 240
321 0101000001 241
322 0101000010 242
323 0101000011 243
324 0101000100 244
325 0101000101 245
326 0101000110 246
327 0101000111 247
328 0101001000 248
329 0101001001 249
336 0101010000 250
337 0101010001 251
338 0101010010 252
339 0101010011 253
340 0101010100 254
341 0101010101 255
342 0101010110 256
343 0101010111 257
344 0101011000 258
345 0101011001 259
352 0101100000 260
353 0101100001 261
354 0101100010 262
355 0101100011 263
356 0101100100 264
357 0101100101 265
358 0101100110 266
359 0101100111 267
360 0101101000 268
361 0101101001 269
368 0101110000 270
369 0101110001 271
370 0101110010 272
371 0101110011 273
372 0101110100 274
373 0101110101 275
374 0101110110 276
375 0101110111 277
376 0101111000 278
377 0101111001 279
266 0100001010 280
267 0100001011 281
298 0100101010 282
299 0100101011 283
330 0101001010 284
331 0101001011 285
362 0101101010 286
363 0101101011 287
302 0100101110 288
303 0100101111 289
282 0100011010 290
283 0100011011 291
314 0100111010 292
315 0100111011 293
346 0101011010 294
347 0101011011 295
378 0101111010 296
379 0101111011 297
318 0100111110 298
319 0100111111 299
384 0110000000 300
385 0110000001 301
386 0110000010 302
387 0110000011 303
388 0110000100 304
389 0110000101 305
390 0110000110 306
391 0110000111 307
392 0110001000 308
393 0110001001 309
400 0110010000 310
401 0110010001 311
402 0110010010 312
403 0110010011 313
404 0110010100 314
405 0110010101 315
406 0110010110 316
407 0110010111 317
408 0110011000 318
409 0110011001 319
416 0110100000 320
417 0110100001 321
418 0110100010 322
419 0110100011 323
420 0110100100 324
421 0110100101 325
422 0110100110 326
423 0110100111 327
424 0110101000 328
425 0110101001 329
432 0110110000 330
433 0110110001 331
434 0110110010 332
435 0110110011 333
436 0110110100 334
437 0110110101 335
438 0110110110 336
439 0110110111 337
440 0110111000 338
441 0110111001 339
448 0111000000 340
449 0111000001 341
450 0111000010 342
451 0111000011 343
452 0111000100 344
453 0111000101 345
454 0111000110 346
455 0111000111 347
456 0111001000 348
457 0111001001 349
464 0111010000 350
465 0111010001 351
466 0111010010 352
467 0111010011 353
468 0111010100 354
469 0111010101 355
470 0111010110 356
471 0111010111 357
472 0111011000 358
473 0111011001 359
480 0111100000 360
481 0111100001 361
482 0111100010 362
483 0111100011 363
484 0111100100 364
485 0111100101 365
486 0111100110 366
487 0111100111 367
488 0111101000 368
489 0111101001 369
496 0111110000 370
497 0111110001 371
498 0111110010 372
499 0111110011 373
500 0111110100 374
501 0111110101 375
502 0111110110 376
503 0111110111 377
504 0111111000 378
505 0111111001 379
394 0110001010 380
395 0110001011 381
426 0110101010 382
427 0110101011 383
458 0111001010 384
459 0111001011 385
490 0111101010 386
491 0111101011 387
430 0110101110 388
431 0110101111 389
410 0110011010 390
411 0110011011 391
442 0110111010 392
443 0110111011 393
474 0111011010 394
475 0111011011 395
506 0111111010 396
507 0111111011 397
446 0110111110 398
447 0110111111 399
512 1000000000 400
513 1000000001 401
514 1000000010 402
515 1000000011 403
516 1000000100 404
517 1000000101 405
518 1000000110 406
519 1000000111 407
520 1000001000 408
521 1000001001 409
528 1000010000 410
529 1000010001 411
530 1000010010 412
531 1000010011 413
532 1000010100 414
533 1000010101 415
534 1000010110 416
535 1000010111 417
536 1000011000 418
537 1000011001 419
544 1000100000 420
545 1000100001 421
546 1000100010 422
547 1000100011 423
548 1000100100 424
549 1000100101 425
550 1000100110 426
551 1000100111 427
552 1000101000 428
553 1000101001 429
560 1000110000 430
561 1000110001 431
562 1000110010 432
563 1000110011 433
564 1000110100 434
565 1000110101 435
566 1000110110 436
567 1000110111 437
568 1000111000 438
569 1000111001 439
576 1001000000 440
577 1001000001 441
578 1001000010 442
579 1001000011 443
580 1001000100 444
581 1001000101 445
582 1001000110 446
583 1001000111 447
584 1001001000 448
585 1001001001 449
592 1001010000 450
593 1001010001 451
594 1001010010 452
595 1001010011 453
596 1001010100 454
597 1001010101 455
598 1001010110 456
599 1001010111 457
600 1001011000 458
601 1001011001 459
608 1001100000 460
609 1001100001 461
610 1001100010 462
611 1001100011 463
612 1001100100 464
613 1001100101 465
614 1001100110 466
615 1001100111 467
616 1001101000 468
617 1001101001 469
624 1001110000 470
625 1001110001 471
626 1001110010 472
627 1001110011 473
628 1001110100 474
629 1001110101 475
630 1001110110 476
631 1001110111 477
632 1001111000 478
633 1001111001 479
522 1000001010 480
523 1000001011 481
554 1000101010 482
555 1000101011 483
586 1001001010 484
587 1001001011 485
618 1001101010 486
619 1001101011 487
558 1000101110 488
559 1000101111 489
538 1000011010 490
539 1000011011 491
570 1000111010 492
571 1000111011 493
602 1001011010 494
603 1001011011 495
634 1001111010 496
635 1001111011 497
574 1000111110 498
575 1000111111 499
640 1010000000 500
641 1010000001 501
642 1010000010 502
643 1010000011 503
644 1010000100 504
645 1010000101 505
646 1010000110 506
647 1010000111 507
648 1010001000 508
649 1010001001 509
656 1010010000 510
657 1010010001 511
658 1010010010 512
659 1010010011 513
660 1010010100 514
661 1010010101 515
662 1010010110 516
663 1010010111 517
664 1010011000 518
665 1010011001 519
672 1010100000 520
673 1010100001 521
674 1010100010 522
675 1010100011 523
676 1010100100 524
677 1010100101 525
678 1010100110 526
679 1010100111 527
680 1010101000 528
681 1010101001 529
688 1010110000 530
689 1010110001 531
690 1010110010 532
691 1010110011 533
692 1010110100 534
693 1010110101 535
694 1010110110 536
695 1010110111 537
696 1010111000 538
697 1010111001 539
704 1011000000 540
705 1011000001 541
706 1011000010 542
707 1011000011 543
708 1011000100 544
709 1011000101 545
710 1011000110 546
711 1011000111 547
712 1011001000 548
713 1011001001 549
720 1011010000 550
721 1011010001 551
722 1011010010 552
723 1011010011 553
724 1011010100 554
725 1011010101 555
726 1011010110 556
727 1011010111 557
728 1011011000 558
729 1011011001 559
736 1011100000 560
737 1011100001 561
738 1011100010 562
739 1011100011 563
740 1011100100 564
741 1011100101 565
742 1011100110 566
743 1011100111 567
744 1011101000 568
745 1011101001 569
752 1011110000 570
753 1011110001 571
754 1011110010 572
755 1011110011 573
756 1011110100 574
757 1011110101 575
758 1011110110 576
759 1011110111 577
760 1011111000 578
761 1011111001 579
650 1010001010 580
651 1010001011 581
682 1010101010 582
683 1010101011 583
714 1011001010 584
715 1011001011 585
746 1011101010 586
747 1011101011 587
686 1010101110 588
687 1010101111 589
666 1010011010 590
667 1010011011 591
698 1010111010 592
699 1010111011 593
730 1011011010 594
731 1011011011 595
762 1011111010 596
763 1011111011 597
702 1010111110 598
703 1010111111 599
768 1100000000 600
769 1100000001 601
770 1100000010 602
771 1100000011 603
772 1100000100 604
773 1100000101 605
774 1100000110 606
775 1100000111 607
776 1100001000 608
777 1100001001 609
784 1100010000 610
785 1100010001 611
786 1100010010 612
787 1100010011 613
788 1100010100 614
789 1100010101 615
790 1100010110 616
791 1100010111 617
792 1100011000 618
793 1100011001 619
800 1100100000 620
801 1100100001 621
802 1100100010 622
803 1100100011 623
804 1100100100 624
805 1100100101 625
806 1100100110 626
807 1100100111 627
808 1100101000 628
809 1100101001 629
816 1100110000 630
817 1100110001 631
818 1100110010 632
819 1100110011 633
820 1100110100 634
821 1100110101 635
822 1100110110 636
823 1100110111 637
824 1100111000 638
825 1100111001 639
832 1101000000 640
833 1101000001 641
834 1101000010 642
835 1101000011 643
836 1101000100 644
837 1101000101 645
838 1101000110 646
839 1101000111 647
840 1101001000 648
841 1101001001 649
848 1101010000 650
849 1101010001 651
850 1101010010 652
851 1101010011 653
852 1101010100 654
853 1101010101 655
854 1101010110 656
855 1101010111 657
856 1101011000 658
857 1101011001 659
864 1101100000 660
865 1101100001 661
866 1101100010 662
867 1101100011 663
868 1101100100 664
869 1101100101 665
870 1101100110 666
871 1101100111 667
872 1101101000 668
873 1101101001 669
880 1101110000 670
881 1101110001 671
882 1101110010 672
883 1101110011 673
884 1101110100 674
885 1101110101 675
886 1101110110 676
887 1101110111 677
888 1101111000 678
889 1101111001 679
778 1100001010 680
779 1100001011 681
810 1100101010 682
811 1100101011 683
842 1101001010 684
843 1101001011 685
874 1101101010 686
875 1101101011 687
814 1100101110 688
815 1100101111 689
794 1100011010 690
795 1100011011 691
826 1100111010 692
827 1100111011 693
858 1101011010 694
859 1101011011 695
890 1101111010 696
891 1101111011 697
830 1100111110 698
831 1100111111 699
896 1110000000 700
897 1110000001 701
898 1110000010 702
899 1110000011 703
900 1110000100 704
901 1110000101 705
902 1110000110 706
903 1110000111 707
904 1110001000 708
905 1110001001 709
912 1110010000 710
913 1110010001 711
914 1110010010 712
915 1110010011 713
916 1110010100 714
917 1110010101 715
918 1110010110 716
919 1110010111 717
920 1110011000 718
921 1110011001 719
928 1110100000 720
929 1110100001 721
930 1110100010 722
931 1110100011 723
932 1110100100 724
933 1110100101 725
934 1110100110 726
935 1110100111 727
936 1110101000 728
937 1110101001 729
944 1110110000 730
945 1110110001 731
946 1110110010 732
947 1110110011 733
948 1110110100 734
949 1110110101 735
950 1110110110 736
951 1110110111 737
952 1110111000 738
953 1110111001 739
960 1111000000 740
961 1111000001 741
962 1111000010 742
963 1111000011 743
964 1111000100 744
965 1111000101 745
966 1111000110 746
967 1111000111 747
968 1111001000 748
969 1111001001 749
976 1111010000 750
977 1111010001 751
978 1111010010 752
979 1111010011 753
980 1111010100 754
981 1111010101 755
982 1111010110 756
983 1111010111 757
984 1111011000 758
985 1111011001 759
992 1111100000 760
993 1111100001 761
994 1111100010 762
995 1111100011 763
996 1111100100 764
997 1111100101 765
998 1111100110 766
999 1111100111 767
1000 1111101000 768
1001 1111101001 769
1008 1111110000 770
1009 1111110001 771
1010 1111110010 772
1011 1111110011 773
1012 1111110100 774
1013 1111110101 775
1014 1111110110 776
1015 1111110111 777
1016 1111111000 778
1017 1111111001 779
906 1110001010 780
907 1110001011 781
938 1110101010 782
939 1110101011 783
970 1111001010 784
971 1111001011 785
1002 1111101010 786
1003 1111101011 787
942 1110101110 788
943 1110101111 789
922 1110011010 790
923 1110011011 791
954 1110111010 792
955 1110111011 793
986 1111011010 794
987 1111011011 795
1018 1111111010 796
1019 1111111011 797
958 1110111110 798
959 1110111111 799
12 0000001100 800
13 0000001101 801
268 0100001100 802
269 0100001101 803
524 1000001100 804
525 1000001101 805
780 1100001100 806
781 1100001101 807
78 0001001110 808
79 0001001111 809
28 0000011100 810
29 0000011101 811
284 0100011100 812
285 0100011101 813
540 1000011100 814
541 1000011101 815
796 1100011100 816
797 1100011101 817
94 0001011110 818
95 0001011111 819
44 0000101100 820
45 0000101101 821
300 0100101100 822
301 0100101101 823
556 1000101100 824
557 1000101101 825
812 1100101100 826
813 1100101101 827
334 0101001110 828
335 0101001111 829
60 0000111100 830
61 0000111101 831
316 0100111100 832
317 0100111101 833
572 1000111100 834
573 1000111101 835
828 1100111100 836
829 1100111101 837
350 0101011110 838
351 0101011111 839
76 0001001100 840
77 0001001101 841
332 0101001100 842
333 0101001101 843
588 1001001100 844
589 1001001101 845
844 1101001100 846
845 1101001101 847
590 1001001110 848
591 1001001111 849
92 0001011100 850
93 0001011101 851
348 0101011100 852
349 0101011101 853
604 1001011100 854
605 1001011101 855
860 1101011100 856
861 1101011101 857
606 1001011110 858
607 1001011111 859
108 0001101100 860
109 0001101101 861
364 0101101100 862
365 0101101101 863
620 1001101100 864
621 1001101101 865
876 1101101100 866
877 1101101101 867
846 1101001110 868
847 1101001111 869
124 0001111100 870
125 0001111101 871
380 0101111100 872
381 0101111101 873
636 1001111100 874
637 1001111101 875
892 1101111100 876
893 1101111101 877
862 1101011110 878
863 1101011111 879
14 0000001110 880
15 0000001111 881
270 0100001110 882
271 0100001111 883
526 1000001110 884
527 1000001111 885
782 1100001110 886
783 1100001111 887
110 0001101110 888
111 0001101111 889
30 0000011110 890
31 0000011111 891
286 0100011110 892
287 0100011111 893
542 1000011110 894
543 1000011111 895
798 1100011110 896
799 1100011111 897
126 0001111110 898
127 0001111111 899
140 0010001100 900
141 0010001101 901
396 0110001100 902
397 0110001101 903
652 1010001100 904
653 1010001101 905
908 1110001100 906
909 1110001101 907
206 0011001110 908
207 0011001111 909
156 0010011100 910
157 0010011101 911
412 0110011100 912
413 0110011101 913
668 1010011100 914
669 1010011101 915
924 1110011100 916
925 1110011101 917
222 0011011110 918
223 0011011111 919
172 0010101100 920
173 0010101101 921
428 0110101100 922
429 0110101101 923
684 1010101100 924
685 1010101101 925
940 1110101100 926
941 1110101101 927
462 0111001110 928
463 0111001111 929
188 0010111100 930
189 0010111101 931
444 0110111100 932
445 0110111101 933
700 1010111100 934
701 1010111101 935
956 1110111100 936
957 1110111101 937
478 0111011110 938
479 0111011111 939
204 0011001100 940
205 0011001101 941
460 0111001100 942
461 0111001101 943
716 1011001100 944
717 1011001101 945
972 1111001100 946
973 1111001101 947
718 1011001110 948
719 1011001111 949
220 0011011100 950
221 0011011101 951
476 0111011100 952
477 0111011101 953
732 1011011100 954
733 1011011101 955
988 1111011100 956
989 1111011101 957
734 1011011110 958
735 1011011111 959
236 0011101100 960
237 0011101101 961
492 0111101100 962
493 0111101101 963
748 1011101100 964
749 1011101101 965
1004 1111101100 966
1005 1111101101 967
974 1111001110 968
975 1111001111 969
252 0011111100 970
253 0011111101 971
508 0111111100 972
509 0111111101 973
764 1011111100 974
765 1011111101 975
1020 1111111100 976
1021 1111111101 977
990 1111011110 978
991 1111011111 979
142 0010001110 980
143 0010001111 981
398 0110001110 982
399 0110001111 983
654 1010001110 984
655 1010001111 985
910 1110001110 986
911 1110001111 987
238 0011101110 988
239 0011101111 989
158 0010011110 990
159 0010011111 991
414 0110011110 992
415 0110011111 993
670 1010011110 994
671 1010011111 995
926 1110011110 996
927 1110011111 997
254 0011111110 998
255 0011111111 999


The 8 decimal values whose digits are all 8s or 9s have four codings each. The bits marked x in the table above are ignored on input, but will always be 0 in computed results. (The 8 × 3 = 24 non-standard encodings fill in the gap from 103 = 1000 and 210 - 1 = 1023.)

Benefit of this encoding is access to individual digits by de- / encoding only 10 bits, disadvantage is that some simple functions like sort and compare, very frequently used in coding, do not work on the bit pattern but require decoding to decimal digits (and evtl. re-encode to binary integers) first.

An alternate encoding in short BID sections, 10 bits declets encoding 0d ... 1023d and simply using only the range from 0 to 999, would provide the same functionality, direct access to digits by de- / encoding 10 bits, with near zero performance penalty in modern systems, and preserve the option for bit-pattern oriented sort and compare, but the 'Sudoku encoding' shown above was chosen in history, may provide better performance in hardware implementations, and now 'is as it is'.

History

[edit]

decimal32 has been introduced in the 2008 version[3] of IEEE 754, adopted by ISO as ISO/IEC/IEEE 60559:2011.[4]

Trivia

[edit]

DPD encoding is relatively efficient, not wasting more than about 2.4 percent of space vs. BID, because the 210 = 1024 possible values in 10 bit is only little more than what is used to encode all numbers from 0 to 999.

Zero has 192 possible representations (384 when both signed zeros are included).

The gain in range and precision by the 'combination encoding' evolves because the taken 2 bits from the exponent only use three states, and the 4 MSBs of the significand stay within 0000 … 1001 (10 states). In total that is 3 × 10 = 30 possible states when combined in one encoding, which is representable in 5 bits ().[clarification needed]

The decimal formats include denormal values, for a graceful degradation of precision near zero, but in contrast to the binary formats they are not marked / do not need a special exponent, in decimal32 they are just values too small to have full 7 digit precision even with the smallest exponent.[clarification needed]

In the cases of infinity and NaN, all other bits of the encoding are ignored. Thus, it is possible to initialize an array to infinities or NaNs by filling it with a single byte value.[citation needed]

See also

[edit]

References

[edit]
  1. ^ 754-2019 - IEEE Standard for Floating-Point Arithmetic ( caution: paywall ). 2019. doi:10.1109/IEEESTD.2019.8766229. ISBN 978-1-5044-5924-2.
  2. ^ Cowlishaw, Michael Frederic (2007-02-13) [2000-10-03]. "A Summary of Densely Packed Decimal encoding". IBM. Archived from the original on 2015-09-24. Retrieved 2016-02-07.
  3. ^ IEEE Computer Society (2008-08-29). IEEE Standard for Floating-Point Arithmetic. IEEE. doi:10.1109/IEEESTD.2008.4610935. ISBN 978-0-7381-5753-5. IEEE Std 754-2008.
  4. ^ "ISO/IEC/IEEE 60559:2011". 2011. Archived from the original on 2016-03-04. Retrieved 2016-02-08.