Microsoft Binary Format
Floating-point formats |
---|
IEEE 754 |
|
Other |
Alternatives |
In
There are two main versions of the format. The original version was designed for memory-constrained systems and stored numbers in 32 bits (4 bytes), with a 23-bit
During the period when it was being ported from the
On
History
Bill Gates and Paul Allen were working on Altair BASIC in 1975. They were developing the software at Harvard University on a DEC PDP-10 running their Altair emulator.[9] One thing they lacked was code to handle floating-point numbers, required to support calculations with very big and very small numbers,[9] which would be particularly useful for science and engineering.[10][11] One of the proposed uses of the Altair was as a scientific calculator.[12]
At a dinner at Currier House, an undergraduate residential house at Harvard, Gates and Allen complained to their dinner companions that they had to write this code[9] and one of them, Monte Davidoff, told them that he had written floating-point routines before and convinced Gates and Allen that he was capable of writing the Altair BASIC floating-point code.[9] At the time, while IBM had introduced their own programs, there was no standard for floating-point numbers, so Davidoff had to come up with his own. He decided that 32 bits would allow enough range and precision.[13] When Allen had to demonstrate it to MITS, it was the first time it ran on an actual Altair.[14] But it worked, and when he entered ‘PRINT 2+2’, Davidoff's adding routine gave the correct answer.[9]
A copy of the source code for Altair BASIC resurfaced in 1999. In the late 1970s, Gates's former tutor and dean Harry Lewis had found it behind some furniture in an office in Aiden, and put it in a file cabinet. After more or less forgetting about its existence for a long time, Lewis eventually came up with the idea of displaying the listing in the lobby. Instead, it was decided on preserving the original listing and producing several copies for display and preservation, after librarian and conservator Janice Merrill-Oldham pointed out its importance.[15][16] A comment in the source credits Davidoff as the writer of Altair BASIC's math package.[15][16]
Altair BASIC took off, and soon most early home computers ran some form of Microsoft BASIC.
In a parallel development,
By the time
Technical details
MBF numbers consist of an 8-bit base-2
The MBF double-precision format provides less scale than the
MBF single-precision format (32 bits, "6-digit BASIC"):[43][8]
Exponent | Sign | Significand |
---|---|---|
8 bits, bit 31–24 |
1 bit, bit 23 |
23 bits, bit 22–0 |
xxxxxxxx | s | mmmmmmmmmmmmmmmmmmmmmmm |
MBF extended-precision format (40 bits, "9-digit BASIC"):[8]
Exponent | Sign | Significand |
---|---|---|
8 bits, bit 39–32 |
1 bit, bit 31 |
31 bits, bit 30–0 |
xxxxxxxx | s | mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm |
MBF double-precision format (64 bits):[43][1]
Exponent | Sign | Significand |
---|---|---|
8 bits, bit 63–56 |
1 bit, bit 55 |
55 bits, bit 54–0 |
xxxxxxxx | s | mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm |
Examples
- 32-bit format: 84h, 20h, 00h, 00h
- 40-bit format: 84h, 20h, 00h, 00h, 00h
- "2":
- 32-bit format: 82h, 00h, 00h, 00h
- 40-bit format: 82h, 00h, 00h, 00h, 00h
- 32-bit format: 81h, 00h, 00h, 00h
- 40-bit format: 81h, 00h, 00h, 00h, 00h
- "0":[43]
- 32-bit format: 00h, 00h, 00h, 00h (or 00h, xxh, xxh, xxh)
- 40-bit format: 00h, 00h, 00h, 00h, 00h (or 00h, xxh, xxh, xxh, xxh)
- 32-bit format: 80h, 00h, 00h, 00h
- 40-bit format: 80h, 00h, 00h, 00h, 00h
- 32-bit format: 7Fh, 00h, 00h, 00h
- 40-bit format: 7Fh, 00h, 00h, 00h, 00h
- 32-bit format: 80h, 80h, 00h, 00h
- 40-bit format: 80h, 80h, 00h, 00h, 00h
- 32-bit format: 80h, 35h, 04h, F3h
- 40-bit format: 80h, 35h, 04h, F3h, 34h
- 32-bit format: 81h, 35h, 04h, F3h
- 40-bit format: 81h, 35h, 04h, F3h, 34h
- 32-bit format: 80h, 31h, 72h, 18h
- 40-bit format: 80h, 31h, 72h, 17h, F8h
- 32-bit format: 81h, 38h, AAh, 3Bh
- 40-bit format: 81h, 38h, AAh, 3Bh, 29h
- 32-bit format: 81h, 49h, 0Fh, DBh
- 40-bit format: 81h, 49h, 0Fh, DAh, A2h
- 32-bit format: 83h, 49h, 0Fh, DBh
- 40-bit format: 83h, 49h, 0Fh, DAh, A2h
See also
- Floating-point arithmetic
- IEEE 754 — Standard for floating-point arithmetic
- IBM hexadecimal floating-point
References
- ^ a b c d "IEEE vs. Microsoft Binary Format; Rounding Issues (Complete)". Microsoft Support. Microsoft. 2006-11-21. Article ID KB35826, Q35826. Archived from the original on 2020-08-28. Retrieved 2010-02-24.
- ^ "(Complete) Tutorial to Understand IEEE Floating-Point Errors". Knowledge Base. Microsoft. 2005-08-16. Article ID KB42980, Q42980. Archived from the original on 2020-08-28. Retrieved 2016-06-02.
- ^ a b "Convert pre-IEEE-754 C++ floating-point numbers to/from C#". stackoverflow.com. 2010-04-21. Archived from the original on 2020-08-28. Retrieved 2016-06-02. (NB. The second reference could be mistaken to say that QB 4.0 could use MBF internally, but it only uses IEEE. It just has a few conversion functions to convert IEEE floating point numbers to strings containing MBF data, e.g. MKDMBF$ in addition to MKD$ which just copies the bytes of the IEEE value to a string.)
- ^ "The MASM 6.1 documentation notes that 5.1 was the last MASM version to support MBF" (PDF). people.sju.edu. Retrieved 2016-06-02.
- ^ GW-BASIC User's Manual, Appendix D.3 USR Function Calls.
- ^ BASIC Second edition (May 1982), IBM: Appendix C-15 (NB. This is the BASICA manual).
- ^ "ROM Routes (Integer Math)". Trs-80.com. Retrieved 2016-06-02.
- ^ a b c d e f g h i j k l m n o p q r Steil, Michael (2008-10-20). "Create your own Version of Microsoft BASIC for 6502". pagetable.com. Archived from the original on 2016-05-30. Retrieved 2016-05-30.
- ^ Harvard Gazette. news.harvard.edu. Archivedfrom the original on 2020-08-28. Retrieved 2016-05-30.
- . (17 pages)
- ^ Leung, K. Ming (2005-02-03) [2000]. "Floating-Point Numbers in Digital Computers" (PDF). cis.poly.edu. Department of Computer and Information Science, Polytechnic University. Archived (PDF) from the original on 2018-12-14. Retrieved 2016-06-02.
- ISBN 978-1-44083014-3. Retrieved 2016-05-30.
- ^ "The Math Package". altairbasic.org. 2014. Archived from the original on 2020-08-28. Retrieved 2016-05-30. (NB. Altair BASIC 3.2 (4K Edition).)
- ^ Orlowski, Andrew (2001-05-11). "Microsoft Altair BASIC legend talks about Linux, CPRM and that very frightening photo - A very rare interview with Monte Davidoff". The Register. Archived from the original on 2020-08-28. Retrieved 2016-05-30.
- ^ a b Orlowski, Andrew (2001-05-13). "Raiders of the Lost Altair BASIC Source Code - They came, they saw … they disassembled". The Register. Archived from the original on 2020-08-28. Retrieved 2016-05-30.
- ^ a b Griffiths, Ian (2000-05-08). "Quest for the Holy Source - Ian's trip to Harvard". Archived from the original on 2002-01-02. Retrieved 2016-05-30.
- ^ "Great people personally responsible for advancing the art of early computers". Oldcomputers.net. 2020-07-18. Archived from the original on 2020-08-28. Retrieved 2016-05-30.
- ^ "Basic 7.0 for Windows". comp.lang.basic.powerbasic.narkive.com. Archived from the original on 2020-08-28. Retrieved 2016-05-30.
- )
- ^ BASIC-80 (MBASIC) Reference Manual (PDF). Retrieved 2016-05-30.
- ^ Microsoft FORTRAN-80 Version 3.4 Users Manual (PDF). November 1980. pp. 45, 55. Retrieved 2016-05-30.
{{cite book}}
:|website=
ignored (help) - ^ Pätzold, Michael, ed. (April 1993). "Zettelsammlung MS-DOS und AT" (in German). Gruppe Datenverarbeitung am MPI für Strömungsforschung Göttingen, Max-Planck-Institut. Archived from the original on 2005-02-20. Retrieved 2015-10-07.
- ^ "Tandy 200 Multiplan Manual" (PDF). classiccmp.org. Retrieved 2016-06-02.
- byte-code which was run by an interpreter, in order to make Multiplan portable across the widely varying hardware of the time. This byte-code distinguished between the machine-specific floating point format to calculate on, and an external (standard) format, which was binary-coded decimal(BCD). The PACK and UNPACK instructions converted between the two.)
- ^ Microsoft COBOL-80 (PDF). 1978. pp. 26, 32. Retrieved 2016-05-30.
{{cite book}}
:|website=
ignored (help) - ^ Lee, Patrick Y. "QWK Mail Packet File Layout" (TXT). textfiles.com. Retrieved 2016-06-02.
- ^ "CSI Millennium (CSIM) format with CSI Y2K extensions". csidata.com. Boca Raton, Florida: Commodity Systems, Inc. 1998-11-17. Archived from the original (TXT) on 2016-03-05. Retrieved 2016-06-02.
[…] This document describes the abandoned CompuTrac data format, which until recently was actively used by Equis' MetaStock charting software. […]
- ^ Billard, Russ (2016-05-04) [2001-07-13]. "Converting Microsoft Binary Format to IEEE format Using VB 6". Archived from the original on 2020-08-28. Retrieved 2016-05-30.
- ^ JerMyster (2003-07-02). "Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6". Tek-Tips. Visual Basic (Classic) Forum. Archived from the original on 2020-08-28. Retrieved 2016-05-30.
- ^ GL88. "Reading Binary Format (QBasic) with C#". Social.msdn.microsoft.com. Retrieved 2016-05-30.
{{cite web}}
: CS1 maint: numeric names: authors list (link) - ^ "Rmetrics - Reading MetaStock data format in R". R.789695.n4.nabble.com. 2013-09-30. Retrieved 2016-05-30.
- ^ a b "Intel and Floating-Point - Updating One of the Industry's Most Successful Standards - The Technology Vision for the Floating-Point Standard" (PDF). Intel. 2016. Archived from the original (PDF) on 2016-03-04. Retrieved 2016-05-30. (11 pages)
- ^ a b "An Interview with the Old Man of Floating-Point". cs.berkeley.edu. 1998-02-20. Retrieved 2016-05-30.
- ^ "VAX Floating Point Numbers". nssdc.gsfc.nasa.gov. Archived from the original on 2020-08-28. Retrieved 2016-06-02. (NB. The VAX-11/780 did not implement the "G" format yet. Although this is not directly apparent from the tables because the structures have been cut up in two-byte words, the byte order is actually the same as on modern CPUs. There isn't enough room in the exponent range for NaNs, Infinity, infinities or denormals.)
- ^ "VAX11 780" (PDF). Ece.cmu.edu. Retrieved 2016-06-02.
- ^ a b "IEEE 754: An Interview with William Kahan" (PDF). dr-chuck.com. Retrieved 2016-06-02.
- (PDF) from the original on 2020-08-28. Retrieved 2016-06-02. (1+13+181+2+2 pages)
- Kahan, William Morton. "Why do we need a floating-point arithmetic standard?"(PDF). cs.berkeley.edu. Retrieved 2016-06-02.
- Kahan, William Morton; Darcy, Joseph D. "How Java's Floating-Point Hurts Everyone Everywhere"(PDF). cs.berkeley.edu. Retrieved 2016-06-02.
- ISBN 978-3-66239812-8. Retrieved 2016-05-30.
- ^ "Names for Standardized Floating-Point Formats" (PDF). cs.berkeley.edu. Retrieved 2016-06-02.
- ^ assumed bit, while IEEE places the decimal point after the assumed bit. […] ieee_exp = msbin[3] - 2; /* actually, msbin[3]-1-128+127 */ […] _dmsbintoieee(double *src8, double *dest8) […] MS Binary Format […] byte order => m7 | m6 | m5 | m4 | m3 | m2 | m1 | exponent […] m1 is most significant byte => smmm|mmmm […] m7 is the least significant byte […] MBF is bias 128 and IEEE is bias 1023. […] MBF places the decimal point before the assumed bit, while IEEE places the decimal point after the assumed bit. […] ieee_exp = msbin[7] - 128 - 1 + 1023; […]
- ^ "Google Groups". Groups.google.com. Retrieved 2016-06-02.
- fractionbits) […] Microsoft Binary Format (single precision) […] The exponent is biased by 128. There is an assumed 1 bit after the radix point (so the assumed mantissa is 0.1ffff… where f's are the fraction bits) […] the IEEE mantissa is twice the MBF mantissa. […] to convert from MBF to IEEE single […] subtract 2 from the exponent (one for the bias change, one for the mantissa factor), and then rearrange the sign and exponent bits. The fraction does not change. To convert from IEEE single to MBF, […] add 2 to the exponent (one for the bias change, one for the mantissa factor), and then rearrange the sign and exponent bits. The fraction does not change. […]
- ^ a b c d e f g h Steil, Michael, ed. (2008-10-20). "msbasic/float.s". MIST64. Archived from the original on 2020-08-28. Retrieved 2020-08-28 – via github.com. [2] (NB. Commented 6502 disassembly listings, merged from several versions of Microsoft BASIC for 6502 between 1977 and 1982 to recreate byte-exact copies of the original ROMs for 10 different machines from different vendors.)
- ^ a b c Steil, Michael, ed. (2008-10-20). "msbasic/trig.s". MIST64. Archived from the original on 2020-08-28. Retrieved 2020-08-28 – via github.com. [3] (NB. Commented 6502 disassembly listings, merged from several versions of Microsoft BASIC for 6502 between 1977 and 1982 to recreate byte-exact copies of the original ROMs for 10 different machines from different vendors.)
Further reading
- Allen, Paul; Gates, Bill; Davidoff, Monte (March 2019) [1975]. Harris, Reuben; Mangin, Charles (eds.). "Altair BASIC 3.2 (4K) - Annotated Disassembly". altairbasic.org. Archived from the original on 2024-03-29. Retrieved 2024-03-29. [4]
- Harris, Reuben, ed. (2014) [1975]. "The Math Package". altairbasic.org. Archived from the original on 2024-03-29. Retrieved 2024-03-29.
External links
- Microsoft provides a dynamic link library for 16-bit Visual Basic containing functions to convert between MBF data and IEEE 754.
- This library wraps the MBF conversion functions in the 16-bit Visual C(++) CRT.
- These conversion functions will round an IEEE double-precision number like ¾ ⋅ 2−128 to zero rather than to 2−128.
- They don't support denormalsat all: the IEEE or MBF single-precision number 2−128 will be converted to zero, even though it is representable in either format.
- This library is only intended for use with Visual Basic; C(++) programs are expected to call the CRT functions directly.
- https://github.com/option8/Altair-BASIC