=========================== Using the MAKEFLOAT program =========================== -IAN! idallen@ncf.ca You can use the MAKEFLOAT program to turn floating point numbers on the command line into bytes in the file FLOAT.BIN that you can then dump using a file dump utility: Dumping under Unix (Linux): $ cc -o makefloat makefloat.c $ ./makefloat -1234.5678 I found number '-1234.567749' I wrote 4 bytes to file 'FLOAT.BIN'. $ od -t x1 FLOAT.BIN 0000000 2b 52 9a c4 0000004 Dumping under DOS: C:\> debug FLOAT.BIN -d 1865:0100 2B 52 9A C4 38 45 FF 75-01 4F 32 C0 AA 07 5F 88 1865:0110 25 47 80 FC 0D 74 04 41-E9 01 FF 26 34 00 54 18 1865:0120 00 74 27 B4 48 BB 41 00-CD 21 72 34 8E C0 33 FF 1865:0130 1E 8E 1E 08 D3 89 3E E3-04 A3 E5 04 1F 8B 36 92 1865:0140 DE E8 45 FA AC AA 3C 0D-75 FA 56 8B 36 92 DE 89 1865:0150 4C FE 5E 8E 06 08 D3 26-80 3E 43 04 00 0E 07 C3 1865:0160 BA 42 86 E9 65 FE BF 81-00 8B 36 92 DE 8B 44 FE 1865:0170 BE C6 DB 8B 74 09 03 C6-50 E8 0D FA 58 E8 5A 00 -q C:\> Both these tests were run on Intel hardware. The bytes are reversed in the dump displays. Many decimal fractions cannot be precisely represented by sums of negative powers of two. For example, no matter how many halves, quarters, eighths, sixteenths, thirty-seconds, etc. you add together, you can never exactly represent "one tenth". So even 1.1 is impossible to represent as an exact IEEE 754 floating point value. Be careful of that fact when you choose numbers on the command line. Unless they can be built up of exact sums of negative powers of two, the resulting fraction will be messy. You will note that the above example "-1234.5678" is very, very messy. You won't get numbers like that on your midterm. Here are two more examples: $ ./makefloat +0.0 I found number '0.000000' I wrote 4 bytes to file 'FLOAT.BIN'. $ od -t x1 FLOAT.BIN 0000000 00 00 00 00 0000004 $ ./makefloat -0.0 I found number '-0.000000' I wrote 4 bytes to file 'FLOAT.BIN'. $ od -t x1 FLOAT.BIN 0000000 00 00 00 80 0000004 Look! Plus and minus zero! Amazing.