1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708
|
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="place"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="date"/>
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>slu</o:Author>
<o:Template>Normal</o:Template>
<o:LastAuthor>slu</o:LastAuthor>
<o:Revision>2</o:Revision>
<o:TotalTime>17366</o:TotalTime>
<o:LastPrinted>2005-05-06T15:24:00Z</o:LastPrinted>
<o:Created>2005-07-12T21:29:00Z</o:Created>
<o:LastSaved>2005-07-12T21:29:00Z</o:LastSaved>
<o:Pages>1</o:Pages>
<o:Words>3396</o:Words>
<o:Characters>19360</o:Characters>
<o:Company>NCSA</o:Company>
<o:Lines>161</o:Lines>
<o:Paragraphs>45</o:Paragraphs>
<o:CharactersWithSpaces>22711</o:CharactersWithSpaces>
<o:Version>10.6714</o:Version>
</o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:GrammarState>Clean</w:GrammarState>
<w:Compatibility>
<w:UseFELayout/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if !mso]><object
classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object>
<style>
st1\:*{behavior:url(#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:\5B8B\4F53;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:SimSun;}
p.MsoDate, li.MsoDate, div.MsoDate
{mso-style-next:Normal;
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:SimSun;}
p
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:SimSun;}
code
{font-family:"Courier New";
mso-ascii-font-family:"Courier New";
mso-fareast-font-family:SimSun;
mso-hansi-font-family:"Courier New";
mso-bidi-font-family:"Courier New";}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:2125927449;
mso-list-type:hybrid;
mso-list-template-ids:2013662716 1284547292 -1954149312 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-number-format:roman-upper;
mso-level-tab-stop:.75in;
mso-level-number-position:left;
margin-left:.75in;
text-indent:-.5in;}
@list l0:level2
{mso-level-tab-stop:.5in;
mso-level-number-position:left;
margin-left:.5in;
text-indent:-.25in;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
table.MsoTableGrid
{mso-style-name:"Table Grid";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
border:solid windowtext 1.0pt;
mso-border-alt:solid windowtext .5pt;
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-border-insideh:.5pt solid windowtext;
mso-border-insidev:.5pt solid windowtext;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]-->
</head>
<body lang=EN-US style='tab-interval:.5in'>
<div class=Section1>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span
style='font-size:14.0pt'><span style='mso-tab-count:2'> </span>Data
Conversion <span class=GramE>Of</span> Arithmetic Data Types<o:p></o:p></span></b></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span
style='mso-tab-count:3'> </span><span
class=SpellE>Quincey</span> <span class=SpellE>Koziol</span> and Raymond Lu<o:p></o:p></b></p>
<p class=MsoNormal><span style='mso-tab-count:4'> </span><st1:date
Year="2005" Day="14" Month="4">April 14, 2005</st1:date></p>
<p class=MsoNormal><span style='mso-tab-count:3'> </span>Revised
on <st1:date Year="2005" Day="12" Month="7">July 12, 2005</st1:date></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.75in;text-indent:0in;mso-list:l0 level1 lfo1;
tab-stops:list .75in'><![if !supportLists]><b style='mso-bidi-font-weight:normal'><span
style='mso-fareast-font-family:"Times New Roman"'><span style='mso-list:Ignore'>I.<span
style='font:7.0pt "Times New Roman"'> </span></span></span></b><![endif]><b
style='mso-bidi-font-weight:normal'>Introduction<o:p></o:p></b></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>This document addresses the HDF5 librarys design and
behaviors of data conversion between arithmetic data types.<span
style='mso-spacerun:yes'> </span>This document is mainly for the HDF5
application users.<span style='mso-spacerun:yes'> </span>It can be also useful
for the HDF5 library developers.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>In this document, the arithmetic data types refer to both
integers and floating-point numbers.<span style='mso-spacerun:yes'> </span>The
integers include all the librarys predefined integers and any user-defined
integers.<span style='mso-spacerun:yes'> </span>The librarys predefined
integers include standard, Intel-specific, Alpha-specific, MIPS-specific, ANSI
C9x-specific, and native data types.<span style='mso-spacerun:yes'> </span>The
<i style='mso-bidi-font-style:normal'>HDF5 Predefined <span class=SpellE>Datatypes</span></i>
section in the <i style='mso-bidi-font-style:normal'>HDF5 Reference Manual</i>
lists all these predefined data types.<span style='mso-spacerun:yes'> </span><span
style='mso-spacerun:yes'></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>For the convenience of discussion in this document, we
repeat all the possible native integers here,</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span style='mso-tab-count:2'> </span>C
types<span style='mso-tab-count:3'> </span>HDF5
types</p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>char</span><span
style='mso-tab-count:3'> </span><span style='mso-tab-count:1'> </span>H5T_NATIVE_CHAR<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>signed</span> char<span
style='mso-tab-count:3'> </span>H5T_NATIVE_SCHAR<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>unsigned</span> char<span
style='mso-tab-count:2'> </span>H5T_NATIVE_UCHAR<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>short</span><span
style='mso-tab-count:4'> </span>H5T_NATIVE_SHORT<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>unsigned</span>
short<span style='mso-tab-count:2'> </span>H5T_NATIVE_USHORT<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=SpellE><span
class=GramE>int</span></span><span style='mso-tab-count:4'> </span>H5T_NATIVE_INT<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>unsigned</span> <span
class=SpellE>int</span><span style='mso-tab-count:2'> </span>H5T_NATIVE_UINT<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>long</span><span
style='mso-tab-count:4'> </span>H5T_NATIVE_LONG<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>unsigned</span> long<span
style='mso-tab-count:2'> </span>H5T_NATIVE_ULONG<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>long</span> <span
class=SpellE>long</span><span style='mso-tab-count:3'> </span>H5T_NATIVE_LLONG<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>unsigned</span> long
<span class=SpellE>long</span><span style='mso-tab-count:1'> </span>H5T_NATIVE_ULLONG<o:p></o:p></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The floating-point numbers include all the librarys
predefined floating-point types and any user-defined types.<span
style='mso-spacerun:yes'> </span>The <i style='mso-bidi-font-style:normal'>HDF5
Reference Manual</i> lists all the predefined types like IEEE, Alpha-specific,
MIPS-specific, and native floating-point data types.<span
style='mso-spacerun:yes'> </span><span style='mso-spacerun:yes'></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Possible native floating-point types are repeated below,</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span style='mso-tab-count:2'> </span>C
types<span style='mso-tab-count:3'> </span>HDF5
types</p>
<p class=MsoNormal><span style='mso-tab-count:2'> </span><span
class=GramE><span style='font-size:10.0pt;font-family:"Courier New"'>float</span></span><span
style='font-size:10.0pt;font-family:"Courier New"'><span style='mso-tab-count:
4'> </span>H5T_NATIVE_FLOAT<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>double</span><span
style='mso-tab-count:1'> </span><span style='mso-tab-count:2'> </span>H5T_NATIVE_DOUBLE<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span><span class=GramE>long</span> double<span
style='mso-tab-count:3'> </span>H5T_NATIVE_LDOUBLE<o:p></o:p></span></p>
<p class=MsoNormal><span style='mso-spacerun:yes'></span></p>
<p class=MsoNormal>For the library, data conversion happens in two
scenarios.<span style='mso-spacerun:yes'> </span>One is when transferring data
between memory and disk through the executions of <span class=GramE><span
style='font-size:10.0pt;font-family:"Courier New"'>H5Dwrite(</span></span><span
style='font-size:10.0pt;font-family:"Courier New"'>) </span>or <span
style='font-size:10.0pt;font-family:"Courier New"'>H5Dread()</span>; another is
when converting data in memory through <span style='font-size:10.0pt;
font-family:"Courier New"'>H5Tconvert()</span>.<span style='mso-spacerun:yes'>
</span>In either case, if the source and destination data types are different,
there will be data conversion.</p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span
style='mso-spacerun:yes'></span><o:p></o:p></b></p>
<p class=MsoNormal style='margin-left:.75in;text-indent:0in;mso-list:l0 level1 lfo1;
tab-stops:list .75in'><![if !supportLists]><b style='mso-bidi-font-weight:normal'><span
style='mso-fareast-font-family:"Times New Roman"'><span style='mso-list:Ignore'>II.<span
style='font:7.0pt "Times New Roman"'> </span></span></span></b><![endif]><b
style='mso-bidi-font-weight:normal'>Hard and Soft Conversions<o:p></o:p></b></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p> </o:p></b></p>
<p class=MsoNormal>The HDF5 library has two ways of converting data for a given
pair of different data types, hard and soft conversions.<span
style='mso-spacerun:yes'> </span><o:p></o:p></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p> </o:p></b></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level2 lfo1;
tab-stops:list .5in'><![if !supportLists]><span style='mso-fareast-font-family:
"Times New Roman"'><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]>Hard vs. Soft Conversions</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>A <i style='mso-bidi-font-style:normal'>hard conversion</i>
is basically a casting done by a compiler, like <span class=SpellE><span
style='font-size:10.0pt;font-family:"Courier New"'>int</span></span><span
style='font-size:10.0pt;font-family:"Courier New"'> a = (<span class=SpellE>int</span><span
class=GramE>)b</span></span>, where <span style='font-size:10.0pt;font-family:
"Courier New"'>b</span> is declared as <span style='font-size:10.0pt;
font-family:"Courier New"'>float</span> type.<span style='mso-spacerun:yes'>
</span>In contrary, a <i style='mso-bidi-font-style:normal'>soft conversion</i>
is done by the HDF5 librarys own conversion functions, where the bit sequence
of the source data are examined and converted into the bit sequence of the
destination data.<span style='mso-spacerun:yes'> </span>The soft conversions tend
to be more rigid although this method is slower than the hard conversions
because of all the bit operations during the conversions.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>During the development of the library, the term <i
style='mso-bidi-font-style:normal'>hardware conversion</i> and <i
style='mso-bidi-font-style:normal'>compiler conversion</i> have been used to
refer to the hard conversion.<span style='mso-spacerun:yes'> </span>The terms <i
style='mso-bidi-font-style:normal'>software conversion</i> and <i
style='mso-bidi-font-style:normal'>library conversion</i> have been used for
the soft conversion.<span style='mso-spacerun:yes'> </span>These terms may be
seen in other documents and the librarys source code.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Internally, the library maintains a list of soft conversion
functions for each pair of source and destination data type classes.<span
style='mso-spacerun:yes'> </span>A data type class is the category to which a
data type belongs.<span style='mso-spacerun:yes'> </span>For example, data type
<span style='font-size:10.0pt;font-family:"Courier New"'>H5T_NATIVE_INT</span>
and <span style='font-size:10.0pt;font-family:"Courier New"'>H5T_NATIVE_LONG</span>
are in the <span style='font-size:10.0pt;font-family:"Courier New"'>H5T_INTEGER</span>
class.<span style='mso-spacerun:yes'> </span>Therefore, soft conversion is
designed to handle any data types in a class including library predefined and
user-defined data types. <span style='mso-spacerun:yes'></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The library also maintains a table of hard conversion
functions for each pair of source and destination data types.<span
style='mso-spacerun:yes'> </span>Function <span style='font-size:10.0pt;
font-family:"Courier New"'>H5T_conv_int_<span class=GramE>float(</span>)</span>
is a hard conversion function.<span style='mso-spacerun:yes'> </span>The
librarys data type conversion path is this table of hard conversion functions,
i.e., hard conversion is always picked first by the library over soft
conversion.<span style='mso-spacerun:yes'> </span>Hard conversion can only
handle native data types because compilers would not recognize any non-native
data types.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>So keep this in mind: soft conversion is for data type
classes while hard conversion is for data types.<span
style='mso-spacerun:yes'> </span>The librarys default conversion between
native data types is hard conversion. <span style='mso-spacerun:yes'></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level2 lfo1;
tab-stops:list .5in'><![if !supportLists]><span style='mso-fareast-font-family:
"Times New Roman"'><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]>Registration and Un-registration of Conversion
Functions</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Users can register their own conversion functions to the
library through the function <span class=GramE><span style='font-size:10.0pt;
font-family:"Courier New"'>H5Tregister(</span></span><span style='font-size:
10.0pt;font-family:"Courier New"'>)</span>.<span style='mso-spacerun:yes'>
</span>These conversion functions can be either soft or hard conversion
functions.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>When a soft conversion function is registered into the
library through function <span class=GramE><span style='font-size:10.0pt;
font-family:"Courier New"'>H5Tregister(</span></span><span style='font-size:
10.0pt;font-family:"Courier New"'>)</span>, it is appended to the list of soft
conversion functions.<span style='mso-spacerun:yes'> </span>It also goes into
the table of hard conversion functions to replace all the conversion functions
which it can apply to.<span style='mso-spacerun:yes'> </span>For example, if a
new soft conversion function <span class=SpellE><span style='font-size:10.0pt;
font-family:"Courier New"'>conv_integer_fp</span></span><span style='font-size:
10.0pt;font-family:"Courier New"'>()</span> which converts any integer to any
floating-point number is registered into the soft list, all hard conversion
functions from any integer to any floating-point types will be replaced by this
soft function.<span style='mso-spacerun:yes'> </span>All <span class=GramE>librarys</span>
conversion paths from integer to floating-point number are updated to this
function.<span style='mso-spacerun:yes'> </span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>When a hard conversion function is registered into the
library, it will go to the table of hard functions and replace existing hard
conversion function.<span style='mso-spacerun:yes'> </span>For example, if a
new function <span class=SpellE><span style='font-size:10.0pt;font-family:"Courier New"'>conv_int_<span
class=GramE>float</span></span></span><span class=GramE><span style='font-size:
10.0pt;font-family:"Courier New"'>(</span></span><span style='font-size:10.0pt;
font-family:"Courier New"'>)</span> which converts data of <span class=SpellE><span
style='font-size:10.0pt;font-family:"Courier New"'>int</span></span> type to <span
style='font-size:10.0pt;font-family:"Courier New"'>float</span> type is
registered as a hard function, it will replace librarys existing conversion
function <span style='font-size:10.0pt;font-family:"Courier New"'>H5T_conv_int_float()</span>.<span
style='mso-spacerun:yes'> </span>The library will use the <span class=SpellE><span
style='font-size:10.0pt;font-family:"Courier New"'>conv_int_<span class=GramE>float</span></span></span><span
class=GramE><span style='font-size:10.0pt;font-family:"Courier New"'>(</span></span><span
style='font-size:10.0pt;font-family:"Courier New"'>)</span> to convert data
from <span class=SpellE><span style='font-size:10.0pt;font-family:"Courier New"'>int</span></span>
to <span style='font-size:10.0pt;font-family:"Courier New"'>float </span>type
if hard conversion is selected.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>On the other hand, if a user wants to un-register some
conversion functions, he or she can use the function <span class=GramE><span
style='font-size:10.0pt;font-family:"Courier New"'>H5Tunregister(</span></span><span
style='font-size:10.0pt;font-family:"Courier New"'>)</span>.<span
style='mso-spacerun:yes'> </span>This function has the same parameters as <span
class=GramE><span style='font-size:10.0pt;font-family:"Courier New"'>H5Tregister(</span></span><span
style='font-size:10.0pt;font-family:"Courier New"'>)</span>. But all of those
parameters are optional.<span style='mso-spacerun:yes'> </span>The missed
parameters will become wild cards, which are used to generalize the criteria.<span
style='mso-spacerun:yes'> </span>For example, if a user wants to disable all
hard conversions to use soft conversions, he or she can simply un-register all
hard conversions by calling</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span style='mso-tab-count:1'> </span><span
class=GramE><code><span style='font-size:10.0pt'>H5Tunregister</span></code><span
style='font-size:10.0pt;font-family:"Courier New"'>(</span></span><em><span
style='font-size:10.0pt;font-family:"Courier New";font-style:normal;mso-bidi-font-style:
italic'>H5T_PERS_HARD</span></em><i style='mso-bidi-font-style:normal'><span
style='font-size:10.0pt;font-family:"Courier New"'>, </span></i><em><span
style='font-size:10.0pt;font-family:"Courier New";font-style:normal;mso-bidi-font-style:
italic'>NULL</span></em><i style='mso-bidi-font-style:normal'><span
style='font-size:10.0pt;font-family:"Courier New"'>, </span></i><em><span
style='font-size:10.0pt;font-family:"Courier New";font-style:normal;mso-bidi-font-style:
italic'>-1</span></em><i style='mso-bidi-font-style:normal'><span
style='font-size:10.0pt;font-family:"Courier New"'>, </span></i><em><span
style='font-size:10.0pt;font-family:"Courier New";font-style:normal;mso-bidi-font-style:
italic'>-1</span></em><i style='mso-bidi-font-style:normal'><span
style='font-size:10.0pt;font-family:"Courier New"'>, </span></i><em><span
style='font-size:10.0pt;font-family:"Courier New";font-style:normal;mso-bidi-font-style:
italic'>NULL</span></em><span style='font-size:10.0pt;font-family:"Courier New"'>);
<span style='mso-spacerun:yes'></span><o:p></o:p></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level2 lfo1;
tab-stops:list .5in'><![if !supportLists]><span style='mso-fareast-font-family:
"Times New Roman"'><span style='mso-list:Ignore'>3.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]>Handling Incorrect Hard Conversions</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>While developing data conversion of the HDF5 library, some
incorrect hard conversions have been discovered.<span
style='mso-spacerun:yes'> </span>Those problems are mainly from compilers
incorrect casting.<span style='mso-spacerun:yes'> </span>We need a good way to
handle these incorrect conversions instead of giving users corrupted data.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Librarys way to handle incorrect hard conversion is to
register no hard conversion function when problematic conversions are detected
during configuration.<span style='mso-spacerun:yes'> </span>In this way, the
librarys conversion path will be the librarys soft conversion function unless
users register their own conversion function.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>To find out whether the library is using a hard or soft
conversion routine for certain pair of source and destination data types, the
function <span style='font-size:10.0pt;font-family:"Courier New"'>H5Tis_hard()</span>
can be used (a proposed reference manual for this new function can be found in
the Appendix of this document).<span style='mso-spacerun:yes'> </span>To find
out the conversion routine that the library is using for certain pair of data
types, the function <span class=GramE><span style='font-size:10.0pt;font-family:
"Courier New"'>H5Tfind(</span></span><span style='font-size:10.0pt;font-family:
"Courier New"'>)</span> should be used.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The table below lists the librarys conversions using soft
routines on some systems and the reason of choosing the soft conversions.<span
style='mso-spacerun:yes'> </span>All the other conversions not listed here are
hard conversions.</p>
<p class=MsoNormal><o:p> </o:p></p>
<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0
style='border-collapse:collapse;border:none;mso-border-alt:solid windowtext .5pt;
mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt;mso-border-insideh:
.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext'>
<tr style='mso-yfti-irow:0'>
<td width=197 valign=top style='width:2.05in;border:solid windowtext 1.0pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>source and
destination data types<o:p></o:p></b></p>
</td>
<td width=197 valign=top style='width:2.05in;border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>system<o:p></o:p></b></p>
</td>
<td width=197 valign=top style='width:2.05in;border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>reason<o:p></o:p></b></p>
</td>
</tr>
<tr style='mso-yfti-irow:1'>
<td width=197 valign=top style='width:2.05in;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>floating-point to floating-point number</p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>all <span class=SpellE>Crays</span></p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><span class=GramE>compiler</span> does not support <span
class=SpellE>denormalized</span> values.</p>
</td>
</tr>
<tr style='mso-yfti-irow:2'>
<td width=197 valign=top style='width:2.05in;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>all integers to long double</p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>all <span class=SpellE>SGIs</span></p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>compiler gives some incorrect conversion</p>
</td>
</tr>
<tr style='mso-yfti-irow:3'>
<td width=197 rowspan=2 valign=top style='width:2.05in;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>unsigned (long) long to floating-point number</p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>all <span class=SpellE>SGIs</span></p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>compiler gives some incorrect conversion</p>
</td>
</tr>
<tr style='mso-yfti-irow:4'>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>64-bit Solaris</p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>compiler does different rounding</p>
</td>
</tr>
<tr style='mso-yfti-irow:5'>
<td width=197 valign=top style='width:2.05in;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>unsigned long <span class=SpellE>long</span> to
floating-point number</p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>Windows Visual Studio 6</p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><o:p> </o:p></p>
</td>
</tr>
<tr style='mso-yfti-irow:6'>
<td width=197 rowspan=2 valign=top style='width:2.05in;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>long double to all integers</p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>all <span class=SpellE>SGIs</span></p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>compiler does some incorrect conversion</p>
</td>
</tr>
<tr style='mso-yfti-irow:7'>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>HP-UX 11.00</p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>Compiler generates floating exception</p>
</td>
</tr>
<tr style='mso-yfti-irow:8;mso-yfti-lastrow:yes'>
<td width=197 valign=top style='width:2.05in;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>floating-point to unsigned long <span class=SpellE>long</span></p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>PGI compiler</p>
</td>
<td width=197 valign=top style='width:2.05in;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>compiler round-up when the fraction part is greater than
0.5</p>
</td>
</tr>
</table>
<p class=MsoNormal><span style='mso-spacerun:yes'></span></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p> </o:p></b></p>
<p class=MsoNormal style='margin-left:.75in;text-indent:0in;mso-list:l0 level1 lfo1;
tab-stops:list .75in'><![if !supportLists]><b style='mso-bidi-font-weight:normal'><span
style='mso-fareast-font-family:"Times New Roman"'><span style='mso-list:Ignore'>III.<span
style='font:7.0pt "Times New Roman"'> </span></span></span></b><![endif]><b
style='mso-bidi-font-weight:normal'>Handling Exception<o:p></o:p></b></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p> </o:p></b></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level2 lfo1;
tab-stops:list .5in'><![if !supportLists]><span style='mso-fareast-font-family:
"Times New Roman"'><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]>How to handle exceptions</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The library has provided the users with the ability to
handle exceptions during data conversion.<span style='mso-spacerun:yes'>
</span>Through the property list function <span style='font-size:10.0pt;
font-family:"Courier New"'>H5Pset_type_conv_<span class=GramE>cb(</span>)</span>,
users callback function can be registered with the library.<span
style='mso-spacerun:yes'> </span>This gives users the control over data values
whenever an exception happens. </p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The following piece of code shows how to register an
exception callback function <span class=SpellE><span style='font-size:10.0pt;
font-family:"Courier New"'>except_<span class=GramE>func</span></span></span><span
class=GramE><span style='font-size:10.0pt;font-family:"Courier New"'>(</span></span><span
style='font-size:10.0pt;font-family:"Courier New"'>) </span>to the library,</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-spacerun:yes'> </span><span class=GramE>if(</span>H5Pset_type_conv_cb(<span
class=SpellE>dxpl_id</span>, <span class=SpellE>except_func</span>, &<span
class=SpellE>fill_value</span>)<0)<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-spacerun:yes'> </span><span class=SpellE><span
class=GramE>goto</span></span> error;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-spacerun:yes'> </span><span class=GramE>if(</span>H5Pget_type_conv_cb(<span
class=SpellE>dxpl_id</span>, &op, &<span class=SpellE>user_data</span>)<0)<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-spacerun:yes'> </span><span class=SpellE><span
class=GramE>goto</span></span> error;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-spacerun:yes'> </span><span class=GramE>if(</span>op != <span
class=SpellE>except_func</span> || *(<span class=SpellE>int</span>*)<span
class=SpellE>user_data</span> != <span class=SpellE>fill_value</span>)<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-spacerun:yes'> </span><span class=SpellE><span
class=GramE>goto</span></span> error;<o:p></o:p></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>It also uses <span style='font-size:10.0pt;font-family:"Courier New"'>H5Pget_type_conv_<span
class=GramE>cb(</span>)</span> to verify that the callback function has been
registered successfully.<span style='mso-spacerun:yes'> </span>The library define
the prototype of the conversion exception callback to be</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:45.0pt'><span class=SpellE><span
class=GramE><code><span style='font-size:10.0pt'>typedef</span></code></span></span>
<em>H5T_conv_ret_t</em> (<code><span style='font-size:10.0pt'>H5Z_conv_except_func_t</span></code>)
(<span class=SpellE><em>int</em></span> <span class=SpellE><code><span
style='font-size:10.0pt'>except_type</span></code></span>, <span class=SpellE><em>hid_t</em></span><em>
*</em><span class=SpellE><code><span style='font-size:10.0pt'>src_id</span></code></span>,
<span class=SpellE><em>hid_t</em></span> *<span class=SpellE><code><span
style='font-size:10.0pt'>dst_id</span></code></span>, <em>void *</em><span
class=SpellE><code><span style='font-size:10.0pt'>src_buf</span></code></span><code><span
style='font-size:10.0pt'>, </span></code><em>void *</em><span class=SpellE><code><span
style='font-size:10.0pt'>dst_buf</span></code></span><code><span
style='font-size:10.0pt'>, </span></code><em>void *</em><span class=SpellE><code><span
style='font-size:10.0pt'>op_data</span></code></span>) <o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>So somewhere in the code, the function <span class=SpellE><span
style='font-size:10.0pt;font-family:"Courier New"'>except_<span class=GramE>func</span></span></span><span
class=GramE><span style='font-size:10.0pt;font-family:"Courier New"'>(</span></span><span
style='font-size:10.0pt;font-family:"Courier New"'>)</span> is defined as</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'>H5T_conv_ret_t <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span class=SpellE><span
style='font-size:10.0pt;font-family:"Courier New"'>except_<span class=GramE>func</span></span></span><span
class=GramE><span style='font-size:10.0pt;font-family:"Courier New"'>(</span></span><span
class=SpellE><span style='font-size:10.0pt;font-family:"Courier New"'>int</span></span><span
style='font-size:10.0pt;font-family:"Courier New"'> <span class=SpellE>except_type</span>,
<span class=SpellE>hid_t</span> <span class=SpellE>src_id</span>, <span
class=SpellE>hid_t</span> <span class=SpellE>dst_id</span>, void *<span
class=SpellE>src_buf</span>, void *<span class=SpellE>dst_buf</span>, void *<span
class=SpellE>user_data</span>)<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'>{<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'>
</span>H5T_conv_ret_t<span style='mso-spacerun:yes'> </span>ret =
H5T_CONV_HANDLED;<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span><span
class=GramE>if(</span><span class=SpellE>except_type</span> ==
H5T_CONV_EXCEPT_RANGE_HI) <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span>/*only
test integer case*/<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span>*(<span
class=SpellE>int</span>*<span class=GramE>)<span class=SpellE>dst</span></span><span
class=SpellE>_buf</span> = *(<span class=SpellE>int</span>*)<span class=SpellE>user_data</span>;<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span><span
class=GramE>else</span> if(<span class=SpellE>except_type</span> ==
H5T_CONV_EXCEPT_RANGE_LOW)<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span>/*only
test integer case*/<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span>*(<span
class=SpellE>int</span>*<span class=GramE>)<span class=SpellE>dst</span></span><span
class=SpellE>_buf</span> = *(<span class=SpellE>int</span>*)<span class=SpellE>user_data</span>;<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span><span
class=GramE>else</span> if(<span class=SpellE>except_type</span> ==
H5T_CONV_EXCEPT_TRUNCATE)<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span><span
class=GramE>ret</span> = H5T_CONV_UNHANDLED; <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span><span
class=GramE>else</span> if(<span class=SpellE>except_type</span> ==
H5T_CONV_EXCEPT_PRECISION)<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span><span
class=GramE>ret</span> = H5T_CONV_UNHANDLED; <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span><span
class=GramE>else</span> if(<span class=SpellE>except_type</span> ==
H5T_CONV_EXCEPT_PINF) <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span>/*only
test integer case*/<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span>*(<span
class=SpellE>int</span>*<span class=GramE>)<span class=SpellE>dst</span></span><span
class=SpellE>_buf</span> = *(<span class=SpellE>int</span>*)<span class=SpellE>user_data</span>;<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span><span
class=GramE>else</span> if(<span class=SpellE>except_type</span> ==
H5T_CONV_EXCEPT_NINF)<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span>/*only
test integer case*/<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span>*(<span
class=SpellE>int</span>*<span class=GramE>)<span class=SpellE>dst</span></span><span
class=SpellE>_buf</span> = *(<span class=SpellE>int</span>*)<span class=SpellE>user_data</span>;<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span><span
class=GramE>else</span> if(<span class=SpellE>except_type</span> ==
H5T_CONV_EXCEPT_NAN)<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span>/*only
test integer case*/<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span>*(<span
class=SpellE>int</span>*<span class=GramE>)<span class=SpellE>dst</span></span><span
class=SpellE>_buf</span> = *(<span class=SpellE>int</span>*)<span class=SpellE>user_data</span>;<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span><span
class=GramE>return</span> ret;<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'>}</span> </p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>This example only handles the cases in which the destination
data type is integer.<span style='mso-spacerun:yes'> </span>The source data
type can be either integer or floating-point number.<span
style='mso-spacerun:yes'> </span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level2 lfo1;
tab-stops:list .5in'><![if !supportLists]><span style='mso-fareast-font-family:
"Times New Roman"'><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]>Cases of Exceptions</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>A number of exceptions may happen during conversion.<span
style='mso-spacerun:yes'> </span>These exceptions are</p>
<p style='margin-left:45.0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_RANGE_<span
class=GramE>HI<span style='font-size:12.0pt;font-family:"Times New Roman"'> :</span></span></span><span
style='mso-spacerun:yes'> </span>source value is positive and is too big to
the destination.<span style='mso-spacerun:yes'> </span>Overflow happens.<span
style='mso-spacerun:yes'>
</span><span style='mso-spacerun:yes'></span></p>
<p style='margin-left:45.0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_RANGE_LOW:</span>
source value is negative and its magnitude is too big to the destination.<span
style='mso-spacerun:yes'> </span>Overflow happens. </p>
<p style='margin-left:45.0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_TRUNCATE:</span>
source is floating-point type and destination is integer.<span
style='mso-spacerun:yes'> </span>The floating-point number has fractional
part. </p>
<p style='margin-left:45.0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_PRECISION:</span>
source is integer and destination is floating-point type.<span
style='mso-spacerun:yes'> </span>The mantissa of floating-point type is not
big enough to hold all the digits of the integer. </p>
<p style='margin-left:45.0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_PINF:</span>
source is floating-point type and the value is positive infinity.</p>
<p style='margin-left:45.0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_NINF:</span>
source is floating-point type and the value is negative infinity.<span
style='mso-spacerun:yes'> </span></p>
<p class=MsoNormal style='margin-left:45.0pt'><span style='font-size:10.0pt;
font-family:"Courier New"'>H5T_CONV_EXCEPT_NAN:</span> source is floating-point
type and the value is <st1:place><span class=SpellE><span class=GramE>NaN</span></span></st1:place><span
class=GramE>(</span>not a number, including <span class=SpellE>QNaN</span> and <span
class=SpellE>SNaN</span>).</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Valid return values of the exception handling callback
function are <code><span style='font-size:10.0pt'>H5T_CONV_ABORT</span></code>,
<span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_UNHANDLED</span>
and <code><span style='font-size:10.0pt'>H5T_CONV_HANDLED</span></code>. <o:p></o:p></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p> </o:p></b></p>
<p class=MsoNormal style='margin-left:.75in;text-indent:0in;mso-list:l0 level1 lfo1;
tab-stops:list .75in'><![if !supportLists]><b style='mso-bidi-font-weight:normal'><span
style='mso-fareast-font-family:"Times New Roman"'><span style='mso-list:Ignore'>IV.<span
style='font:7.0pt "Times New Roman"'> </span></span></span></b><![endif]><b
style='mso-bidi-font-weight:normal'>Soft Data Conversions<o:p></o:p></b></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p> </o:p></b></p>
<p class=MsoNormal>This section is mainly for advanced users or library
developers who want to know the librarys behavior in performing soft data
conversion.<span style='mso-spacerun:yes'> </span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level2 lfo1;
tab-stops:list .5in'><![if !supportLists]><span style='mso-fareast-font-family:
"Times New Roman"'><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]>Understanding Bit Patterns of Arithmetic Data
Types</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>In order to understand data conversion, it will be helpful
for us to know about the bit patterns of arithmetic data types.<span
style='mso-spacerun:yes'> </span>Integers generally have simple bit
patterns.<span style='mso-spacerun:yes'> </span>Using the twos-complement
notation, a signed integer of <span style='font-size:10.0pt;font-family:"Courier New"'>n</span>
bits in size will have a range from -2<sup>n-1</sup> to 2<sup>n-1</sup>
1.<span style='mso-spacerun:yes'> </span>The high-order bit is the sign
bit.<span style='mso-spacerun:yes'> </span>There are <span style='font-size:
10.0pt;font-family:"Courier New"'>n-1</span> data bits.<span
style='mso-spacerun:yes'> </span>For unsigned integers, the high-order bit
becomes a data bit.<span style='mso-spacerun:yes'> </span>All the <span
style='font-size:10.0pt;font-family:"Courier New"'>n</span> bits are data
bits.<span style='mso-spacerun:yes'> </span>So an unsigned integer of <span
style='font-size:10.0pt;font-family:"Courier New"'>n</span> bit in size has a
range from <span style='font-size:10.0pt;font-family:"Courier New"'>0</span> to
<span style='font-size:10.0pt;font-family:"Courier New"'>2<sup>n</sup>1</span>.<span
style='mso-spacerun:yes'> </span>An example bit sequence of <span
style='font-size:10.0pt;font-family:"Courier New"'>(signed) char</span> of 1
byte long is like <span style='font-size:10.0pt;font-family:"Courier New"'>10010111</span>.<span
style='mso-spacerun:yes'> </span>The high-order (leftmost) bit is set to 1,
meaning the value is negative.<span style='mso-spacerun:yes'> </span>If the same
bit sequence represents an <span style='font-size:10.0pt;font-family:"Courier New"'>unsigned
char</span>, the high-order bit becomes a data bit, making the value be 151.<span
style='mso-spacerun:yes'> </span>Any implementation of C language has the
ranges of the native integer types documented in the header file <span
class=SpellE><span style='font-size:10.0pt;font-family:"Courier New"'>limits.h</span></span>.<span
style='mso-spacerun:yes'> </span>For example, the ranges of <span
style='font-size:10.0pt;font-family:"Courier New"'>short</span> type are <span
style='font-size:10.0pt;font-family:"Courier New"'>SHRT_MAX = 32,767</span> and
<span style='font-size:10.0pt;font-family:"Courier New"'>SHRT_MIN = -32,767</span>.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The floating-point number representation is more
complicated.<span style='mso-spacerun:yes'> </span>A more thorough description
of IEEE standard floating-point numbers can be found in the <i
style='mso-bidi-font-style:normal'>IEEE Standard 754</i> document.<span
style='mso-spacerun:yes'> </span>For IEEE standard floating-point numbers, there
are three components for a floating-point number, the sign, the exponent, and
the mantissa.<span style='mso-spacerun:yes'> </span>The diagram below shows
the layouts of IEEE <span style='font-size:10.0pt;font-family:"Courier New"'>float</span>
and <span style='font-size:10.0pt;font-family:"Courier New"'>double</span>
types.</p>
<p class=MsoNormal><o:p> </o:p></p>
<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0
style='margin-left:23.4pt;border-collapse:collapse;border:none;mso-border-alt:
solid windowtext .5pt;mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-border-insideh:.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext'>
<tr style='mso-yfti-irow:0'>
<td width=87 valign=top style='width:65.15pt;border:solid windowtext 1.0pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>Type<o:p></o:p></b></p>
</td>
<td width=118 valign=top style='width:88.55pt;border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>Sign<o:p></o:p></b></p>
</td>
<td width=118 valign=top style='width:88.55pt;border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>Exponent<o:p></o:p></b></p>
</td>
<td width=118 valign=top style='width:88.55pt;border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>Mantissa<o:p></o:p></b></p>
</td>
<td width=87 valign=top style='width:65.2pt;border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>Bias<o:p></o:p></b></p>
</td>
</tr>
<tr style='mso-yfti-irow:1'>
<td width=87 valign=top style='width:65.15pt;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>float<o:p></o:p></span></p>
</td>
<td width=118 valign=top style='width:88.55pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>1[31]</p>
</td>
<td width=118 valign=top style='width:88.55pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>8[30-23]</p>
</td>
<td width=118 valign=top style='width:88.55pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>23[22-00]</p>
</td>
<td width=87 valign=top style='width:65.2pt;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>127</p>
</td>
</tr>
<tr style='mso-yfti-irow:2;mso-yfti-lastrow:yes'>
<td width=87 valign=top style='width:65.15pt;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>double<o:p></o:p></span></p>
</td>
<td width=118 valign=top style='width:88.55pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>1[63]</p>
</td>
<td width=118 valign=top style='width:88.55pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>11[62-52]</p>
</td>
<td width=118 valign=top style='width:88.55pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>52[51-00]</p>
</td>
<td width=87 valign=top style='width:65.2pt;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>1023</p>
</td>
</tr>
</table>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The numbers are the size of each component.<span
style='mso-spacerun:yes'> </span>The bit index is in the square brackets.<span
style='mso-spacerun:yes'> </span>To calculate the true exponent value, the
bias has to be subtracted from the value represented by the bits of
exponent.<span style='mso-spacerun:yes'> </span>The mantissa represents the
precision bits.<span style='mso-spacerun:yes'> </span>The leading bit has been
implied.<span style='mso-spacerun:yes'> </span>When the true precision is
calculated, this implicit bit will be restored.<span style='mso-spacerun:yes'>
</span>Consider this bit sequence for float in little-endian order,</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><span
style='mso-tab-count:2'> </span>Byte 3<span style='mso-tab-count:
1'> </span>byte 2<span style='mso-tab-count:1'> </span>byte 1<span
style='mso-tab-count:1'> </span>byte 0<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:.5in'><span style='font-size:10.0pt;
font-family:"Courier New"'><span style='mso-spacerun:yes'> </span>11000011<span
style='mso-tab-count:1'> </span>11110000<span style='mso-tab-count:1'> </span>00000000<span
style='mso-tab-count:1'> </span>00000000</span> </p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The high-order (leftmost) bit is the sign bit.<span
style='mso-spacerun:yes'> </span>It is set to indicate the number is
negative.<span style='mso-spacerun:yes'> </span>The eight bits after the sign
bit, <span class=GramE><span style='font-size:10.0pt;font-family:"Courier New"'>10000111</span>
in <span style='font-size:10.0pt;font-family:"Courier New"'>byte 3</span> and <span
style='font-size:10.0pt;font-family:"Courier New"'>2</span>,</span> is the
exponent.<span style='mso-spacerun:yes'> </span>The value of these eight bits
is 135.<span style='mso-spacerun:yes'> </span>After subtracting the bias 127,
the true exponent is 8.<span style='mso-spacerun:yes'> </span>The 23 bits
after the exponent <span style='font-size:10.0pt;font-family:"Courier New"'>1110000
00000000 <span class=SpellE>00000000</span></span> in <span style='font-size:
10.0pt;font-family:"Courier New"'>byte 2, 1, 0</span>, is the mantissa.<span
style='mso-spacerun:yes'> </span>After restoring the implicit leading bit and
adding the radix, the mantissa becomes <span style='font-size:10.0pt;
font-family:"Courier New"'>1.1110000 00000000 <span class=SpellE>00000000</span></span>.<span
style='mso-spacerun:yes'> </span>The value of this float number is <span
style='font-size:10.0pt;font-family:"Courier New"'>1.111 x 2<sup>8</sup> =
111100000.0 = 480.0</span>.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>There are a few special values for floating-point numbers,</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in'><span class=SpellE><i
style='mso-bidi-font-style:normal'>Denormalized</i></span> when exponent bits
are all 0s but mantissa bits are non-zero.<span style='mso-spacerun:yes'>
</span>There will be no implicit bit for the mantissa.</p>
<p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in'><i style='mso-bidi-font-style:normal'>Zero</i>
when exponent and mantissa bits are all set to 0s.<span
style='mso-spacerun:yes'> </span>There can be both +0 and -0.</p>
<p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in'><i style='mso-bidi-font-style:normal'>Infinity</i>
when exponent bits are all 1s and mantissa bits are all 0s.<span
style='mso-spacerun:yes'> </span>There can be both positive and negative
infinities.</p>
<p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in'><st1:place><span class=SpellE><span
class=GramE><i style='mso-bidi-font-style:normal'>NaN</i></span></span></st1:place><span
class=GramE>(</span>Not a Number) when exponent bits are all 1s and mantissa bits
are not all 0s.<span style='mso-spacerun:yes'> </span><st1:place><span
class=SpellE>NaN</span></st1:place> can be either positive or negative.<span
style='mso-spacerun:yes'> </span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>For other predefined or used-defined types, they should be
similar to IEEE standard.<span style='mso-spacerun:yes'> </span>There should
be the sign, exponent, mantissa, and bias.<span style='mso-spacerun:yes'>
</span>The bits of exponent or mantissa should be contiguous.<span
style='mso-spacerun:yes'> </span></p>
<p class=MsoNormal><span style='mso-tab-count:1'> </span><span
style='mso-spacerun:yes'></span></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level2 lfo1;
tab-stops:list .5in'><![if !supportLists]><span style='mso-fareast-font-family:
"Times New Roman"'><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]>Between Integer and Integer Types</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Generally, converting from one integer type to another
should result in the same mathematical value.<span style='mso-spacerun:yes'>
</span>There are some cases that overflow may happen.<span
style='mso-spacerun:yes'> </span>If overflow happens, the library will let
users exception handling function to handle if this function is available.<span
style='mso-spacerun:yes'> </span>The two exceptions relating to this kind of
conversion are <span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_RANGE_HI</span>
and <span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_RANGE_LOW</span>.<span
style='mso-spacerun:yes'> </span>Otherwise, the librarys default way is to
assign maximal or minimal value to the destination type.<span
style='mso-spacerun:yes'> </span>To the library, the maximal value is that all
data bit of an integer is set to 1s.<span style='mso-spacerun:yes'> </span>The
minimal value is that all data bit of an unsigned integer is set to 0s, or that
only the sign bit of a signed integer is set to 1.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The following table lists all possible scenarios when
overflow can happen and the values assigned to the destination.</p>
<p class=MsoNormal><o:p> </o:p></p>
<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0
style='border-collapse:collapse;border:none;mso-border-alt:solid windowtext .5pt;
mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt;mso-border-insideh:
.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext'>
<tr style='mso-yfti-irow:0'>
<td width=148 valign=top style='width:110.7pt;border:solid windowtext 1.0pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>Source type<o:p></o:p></b></p>
</td>
<td width=148 valign=top style='width:110.7pt;border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>Destination type<o:p></o:p></b></p>
</td>
<td width=148 valign=top style='width:110.7pt;border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>When source value
may be out of the range of destination and overflow happens<o:p></o:p></b></p>
</td>
<td width=148 valign=top style='width:110.7pt;border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>Value assigned to
destination when overflows<o:p></o:p></b></p>
</td>
</tr>
<tr style='mso-yfti-irow:1'>
<td width=148 valign=top style='width:110.7pt;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>unsigned</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>unsigned</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>source size > destination size</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>maximum</p>
</td>
</tr>
<tr style='mso-yfti-irow:2'>
<td width=148 rowspan=2 valign=top style='width:110.7pt;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>signed </p>
</td>
<td width=148 rowspan=2 valign=top style='width:110.7pt;border-top:none;
border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>unsigned</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>source data bit size > destination data bit size</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>maximum</p>
</td>
</tr>
<tr style='mso-yfti-irow:3'>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>source value < 0</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>0</p>
</td>
</tr>
<tr style='mso-yfti-irow:4'>
<td width=148 valign=top style='width:110.7pt;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>unsigned</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>signed</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>source data bit size > destination data bit size</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>maximum</p>
</td>
</tr>
<tr style='mso-yfti-irow:5'>
<td width=148 rowspan=2 valign=top style='width:110.7pt;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>signed </p>
</td>
<td width=148 rowspan=2 valign=top style='width:110.7pt;border-top:none;
border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>signed</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>source value < 0; source size > destination size</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>minimum</p>
</td>
</tr>
<tr style='mso-yfti-irow:6;mso-yfti-lastrow:yes'>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>source value > 0;</p>
<p class=MsoNormal>Source size > destination size</p>
</td>
<td width=148 valign=top style='width:110.7pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal>maximum</p>
</td>
</tr>
</table>
<p class=MsoNormal><span style='mso-spacerun:yes'> </span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level2 lfo1;
tab-stops:list .5in'><![if !supportLists]><span style='mso-fareast-font-family:
"Times New Roman"'><span style='mso-list:Ignore'>3.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]>From Integer To Floating-point Number</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>When the library converts integer to floating-point number,
the result should be equal to the original value except two cases.<span
style='mso-spacerun:yes'> </span>One is when the mantissa of floating-point is
not big enough to hold all the digits of integer, there will be some precision
loss.<span style='mso-spacerun:yes'> </span>In this case, an exception of <span
style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_PRECISION</span>
will be returned if users exception handling has been registered with the
library.<span style='mso-spacerun:yes'> </span>Otherwise, the library will
round up or round down the source integer to the closest floating-point number.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Another case is when the integer value is beyond the range
of floating-point number, overflow happens.<span style='mso-spacerun:yes'>
</span>The exception <span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_RANGE_HI</span>
or <span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_RANGE_LOW</span>
is returned to users exception handling function.<span
style='mso-spacerun:yes'> </span>If users exception handling function is
absent, the library will assign the value of positive or negative infinity to
the destination.<span style='mso-spacerun:yes'> </span>However, this case does
not happen often because floating-point numbers have broad ranges.<span
style='mso-spacerun:yes'> </span><span style='font-size:10.0pt;font-family:
"Courier New"'><span style='mso-spacerun:yes'></span></span><span
style='mso-spacerun:yes'></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level2 lfo1;
tab-stops:list .5in'><![if !supportLists]><span style='mso-fareast-font-family:
"Times New Roman"'><span style='mso-list:Ignore'>4.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]>From Floating-point Number To Integer</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The conversion from floating-point number to integer results
the same value if the floating-point number does not have fractional part.<span
style='mso-spacerun:yes'> </span>If the fractional part is non-zero, the
library will return an exception of <span style='font-size:10.0pt;font-family:
"Courier New"'>H5T_CONV_EXCEPT_TRUNCATE</span> to the users exception handling
function.<span style='mso-spacerun:yes'> </span>If this function is absent,
the library will discard the fractional part.<span style='mso-spacerun:yes'>
</span>The conversion from floating-point number to integer usually involves
truncating of the fractional part. </p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Because floating-point numbers normally have greater ranges
than integers, overflow may happen.<span style='mso-spacerun:yes'> </span>The
library returns the exceptions of <span style='font-size:10.0pt;font-family:
"Courier New"'>H5T_CONV_EXCEPT_RANGE_HI</span> and <span style='font-size:10.0pt;
font-family:"Courier New"'>H5T_CONV_EXCEPT_RANGE_LOW</span> to the users
exception handling function.<span style='mso-spacerun:yes'> </span>If such
function is absent, the library will set the maximal (set all data bits to 1s)
or minimal (set all data bits to 0s for unsigned integer; set only the sign bit
to 1 for signed integer) values for the integer.<span
style='mso-spacerun:yes'> </span>This is similar to conversion between integer
and integer.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Floating-point numbers have some special values.<span
style='mso-spacerun:yes'> </span>These values are +/-0, +/-infinity, and <st1:place><span
class=SpellE>NaN</span></st1:place>.<span style='mso-spacerun:yes'>
</span>For +/-0, the library simply converts them to 0 for the integer.<span
style='mso-spacerun:yes'> </span>For +/-infinity, the exception <span
class=GramE>of<span style='mso-spacerun:yes'> </span><span style='font-size:
10.0pt;font-family:"Courier New"'>H5T</span></span><span style='font-size:10.0pt;
font-family:"Courier New"'>_CONV_EXCEPT_PINF</span> or <span style='font-size:
10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_NINF</span> is returned to
the users exception handling function.<span style='mso-spacerun:yes'>
</span>If no such function, the library will assign the maximal or minimal
values to the integer.<span style='mso-spacerun:yes'> </span>For <st1:place><span
class=SpellE>NaN</span></st1:place>, the library returns the exception <span
style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_NAN</span>.<span
style='mso-spacerun:yes'> </span>The librarys default way is to assign the
value 0 to the integer for <st1:place><span class=SpellE>NaN</span></st1:place>.<span
style='mso-spacerun:yes'> </span><span style='mso-spacerun:yes'></span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level2 lfo1;
tab-stops:list .5in'><![if !supportLists]><span style='mso-fareast-font-family:
"Times New Roman"'><span style='mso-list:Ignore'>5.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]>Between Floating-point and Floating-point
Numbers</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The conversion between two floating-point numbers involves
more issues to consider.<span style='mso-spacerun:yes'> </span>Converting from
a smaller floating-point number like <span style='font-size:10.0pt;font-family:
"Courier New"'>float</span> to a bigger type like <span style='font-size:10.0pt;
font-family:"Courier New"'>double</span> should result in the same value.<span
style='mso-spacerun:yes'> </span>Converting from a bigger type like <span
style='font-size:10.0pt;font-family:"Courier New"'>double</span> to a smaller
type like <span style='font-size:10.0pt;font-family:"Courier New"'>float</span>
has three problems to be taken care of.<span style='mso-spacerun:yes'> </span>One
is that if the source value is within the range of the destination, there can be
some precision loss because the source mantissa is bigger than the destination
mantissa.<span style='mso-spacerun:yes'> </span>The library will do rounding
to make the result be closest to the original value.<span
style='mso-spacerun:yes'> </span>Another one is that if the source value is
beyond the range of the destination, overflow happens.<span
style='mso-spacerun:yes'> </span>The library will return the exception of <span
style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_RANGE_HI</span>
or <span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_RANGE_LOW</span>
to users exception handling function.<span style='mso-spacerun:yes'> </span>If
no such a function is present, the library will assign infinity to the
destination.<span style='mso-spacerun:yes'> </span>The third issue is that if
the source value is very small, the library will try to <span class=SpellE>denormalize</span>
the destination.<span style='mso-spacerun:yes'> </span>If it is still too
small for the destination, underflow happens.<span style='mso-spacerun:yes'>
</span>The library simply assigns 0 to the destination.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>For the special values of floating-point numbers, +/-0,
+/-infinity, and <st1:place><span class=SpellE>NaN</span></st1:place>, the
librarys default way is to assign the same special values to the
destination.<span style='mso-spacerun:yes'> </span>But if the users exception
handling function is present, the library will returns exception to it.<span
style='mso-spacerun:yes'> </span>For positive infinity, the exception is <span
style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_PINF</span>;
for the negative infinity, the exception is <span style='font-size:10.0pt;
font-family:"Courier New"'>H5T_CONV_EXCEPT_NINF</span>; for the Not a Number,
the exception is <span style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_NAN.</span></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p> </o:p></b></p>
<p class=MsoNormal style='margin-left:.75in;text-indent:0in;mso-list:l0 level1 lfo1;
tab-stops:list .75in'><![if !supportLists]><b style='mso-bidi-font-weight:normal'><span
style='mso-fareast-font-family:"Times New Roman"'><span style='mso-list:Ignore'>V.<span
style='font:7.0pt "Times New Roman"'> </span></span></span></b><![endif]><b
style='mso-bidi-font-weight:normal'>Hard Data Conversions<o:p></o:p></b></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p> </o:p></b></p>
<p class=MsoNormal>Because the details are handled by compilers, the library
has little control over hard conversion.<span style='mso-spacerun:yes'>
</span>The librarys control is mainly on overflow.<span
style='mso-spacerun:yes'> </span>When the source value is beyond the ranges of
the destination, overflow happens.<span style='mso-spacerun:yes'> </span>Just
like the soft conversion, the library will signal <span style='font-size:10.0pt;
font-family:"Courier New"'>H5T_CONV_EXCEPT_RANGE_HI</span> or <span
style='font-size:10.0pt;font-family:"Courier New"'>H5T_CONV_EXCEPT_RANGE_LOW</span>
to users exception handling function.<span style='mso-spacerun:yes'>
</span>If no such a function is present, the library will assign maximal or
minimal values to the destination.<span style='mso-spacerun:yes'> </span>These
maximal or minimal values are found in the C librarys header file <span
class=SpellE><span style='font-size:10.0pt;font-family:"Courier New"'>limits.h</span></span>
for integers or <span class=SpellE><span style='font-size:10.0pt;font-family:
"Courier New"'>floats.h</span></span> for floating-point numbers.<span
style='mso-spacerun:yes'> </span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>For integers, these values can be different from the maximal
and minimal values of soft conversion because they are defined by specific C
library implementation.<span style='mso-spacerun:yes'> </span>For example, the
<span style='font-size:10.0pt;font-family:"Courier New"'>INT_MAX</span> (maximal
<span class=SpellE><span style='font-size:10.0pt;font-family:"Courier New"'>int</span></span>)
can be defined as 32,767 and the <span style='font-size:10.0pt;font-family:
"Courier New"'>INT_MIN</span> (minimal <span class=SpellE><span
style='font-size:10.0pt;font-family:"Courier New"'>int</span></span>) can be
defined as -32,767.<span style='mso-spacerun:yes'> </span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>For floating-point numbers, the soft conversion sets the
destination to positive or negative infinity when overflow happens.<span
style='mso-spacerun:yes'> </span>The hard conversion will set to the maximal
values found in Cs header file <span class=SpellE><span style='font-size:10.0pt;
font-family:"Courier New"'>floats.h</span></span>.<span
style='mso-spacerun:yes'> </span>For example, the <span style='font-size:10.0pt;
font-family:"Courier New"'>FLT_<span class=GramE>MAX<span style='font-size:
12.0pt;font-family:"Times New Roman"'>(</span></span></span>maximal <span
style='font-size:10.0pt;font-family:"Courier New"'>float</span>) can be defined
as 10<sup>+37</sup> and the minimal value is simply <span style='font-size:
10.0pt;font-family:"Courier New"'>FLT_MAX</span>.<span
style='mso-spacerun:yes'> </span><o:p></o:p></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p> </o:p></b></p>
<p class=MsoNormal style='margin-left:.75in;text-indent:0in;mso-list:l0 level1 lfo1;
tab-stops:list .75in'><![if !supportLists]><b style='mso-bidi-font-weight:normal'><span
style='mso-fareast-font-family:"Times New Roman"'><span style='mso-list:Ignore'>VI.<span
style='font:7.0pt "Times New Roman"'> </span></span></span></b><![endif]><b
style='mso-bidi-font-weight:normal'>Summary<o:p></o:p></b></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p> </o:p></b></p>
<p class=MsoNormal>Generally speaking, during data conversion, the HDF5 library
tries to convert the original value to the same mathematical <span class=GramE>value,</span>
or close to the original value if the same value is not possible.</p>
<p class=MsoNormal><span style='mso-spacerun:yes'> </span><o:p></o:p></p>
<p class=MsoNormal>The way that HDF5 library deals with overflow and underflow may
not be the same as some C implementations.<span style='mso-spacerun:yes'>
</span>For the special values of floating-point numbers, the library may behave
differently from some C implementations, too.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'>Appendix:<o:p></o:p></b></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><strong>Name:</strong> <a name=Datatype-Find>H5T</a>is_hard </p>
<p class=MsoNormal><strong>Signature:</strong> </p>
<p class=MsoNormal style='margin-left:.5in'><span class=SpellE><em>herr_t</em></span>
<code><span style='font-size:10.0pt'>H5Tis_<span class=GramE>hard<span
style='font-size:12.0pt;font-family:"Times New Roman"'>(</span></span></span></code><span
class=SpellE><em>hid_t</em></span> <span class=SpellE><code><span
style='font-size:10.0pt'>src_id</span></code></span>, <span class=SpellE><em>hid_t</em></span>
<span class=SpellE><code><span style='font-size:10.0pt'>dst_id</span></code></span>)
</p>
<p class=MsoNormal><strong>Purpose:</strong> </p>
<p class=MsoNormal style='margin-left:.5in'>Check whether the librarys default
conversion is hard conversion. </p>
<p class=MsoNormal><strong>Description:</strong> </p>
<p class=MsoNormal style='margin-left:.5in'><code><span style='font-size:10.0pt'>H5Tis_hard</span></code>
finds out whether the librarys conversion function from type <span
class=SpellE><code><span style='font-size:10.0pt'>src_id</span></code></span>
to type <span class=SpellE><code><span style='font-size:10.0pt'>dst_id</span></code></span>
is a hard conversion.<span style='mso-spacerun:yes'> </span>A hard conversion
uses compilers casting; a soft conversion uses the librarys own conversion
function. </p>
<p class=MsoNormal><strong>Parameters:</strong> </p>
<table class=MsoNormalTable border=0 cellpadding=0 style='mso-cellspacing:1.5pt;
margin-left:.5in'>
<tr style='mso-yfti-irow:0'>
<td valign=top style='padding:.75pt .75pt .75pt .75pt'>
<p class=MsoNormal><span class=SpellE><em>hid_t</em></span> <span
class=SpellE><code><span style='font-size:10.0pt'>src_id</span></code></span></p>
</td>
<td valign=top style='padding:.75pt .75pt .75pt .75pt'>
<p class=MsoNormal>IN: Identifier for the source <span class=SpellE>datatype</span>.</p>
</td>
</tr>
<tr style='mso-yfti-irow:1;mso-yfti-lastrow:yes'>
<td valign=top style='padding:.75pt .75pt .75pt .75pt'>
<p class=MsoNormal><span class=SpellE><em>hid_t</em></span> <span
class=SpellE><code><span style='font-size:10.0pt'>dst_id</span></code></span></p>
</td>
<td valign=top style='padding:.75pt .75pt .75pt .75pt'>
<p class=MsoNormal>IN: Identifier for the destination <span class=SpellE>datatype</span>.</p>
</td>
</tr>
</table>
<p class=MsoNormal><strong>Returns:</strong> </p>
<p class=MsoNormal style='margin-left:.5in'>Returns TRUE for hard conversion,
FALSE for soft conversion. </p>
<p class=MsoNormal><strong>Fortran90 Interface:</strong> </p>
<p class=MsoNormal style='margin-left:.5in'><span class=GramE>None.</span><o:p></o:p></p>
</div>
</body>
</html>
|