Floatingpoint formats 

IEEE 754 

Other 
Alternatives 
In computing, Microsoft Binary Format (MBF) is a format for floatingpoint numbers which was used in Microsoft's BASIC languages, including MBASIC, GWBASIC and QuickBASIC prior to version 4.00.^{[1]}^{[2]}^{[3]}^{[4]}^{[5]}^{[6]}^{[7]}
There are two main versions of the format. The original version was designed for memoryconstrained systems and stored numbers in 32 bits (4 bytes), with a 23bit mantissa, 1bit sign, and an 8bit exponent. Extended (12k) BASIC included a doubleprecision type with 64 bits.
During the period when it was being ported from the Intel 8080 platform to the MOS 6502 processor, computers were beginning to ship with more memory as a standard feature. This version was offered with the original 32bit format or an optional expanded 40bit (5byte) format. The 40bit format was used by most home computers of the 1970s and 1980s. These two versions are sometimes known as "6digit" and "9digit", respectively.^{[8]}
On PCs with x86 processor, QuickBASIC, prior to version 4, reintroduced the doubleprecision format using a 55bit mantissa in a 64bit (8byte) format. MBF was abandoned during the move to QuickBASIC 4, which used the standard IEEE 754 format, introduced a few years earlier.
Bill Gates and Paul Allen were working on Altair BASIC in 1975. They were developing the software at Harvard University on a DEC PDP10 running their Altair emulator.^{[9]} One thing they lacked was code to handle floatingpoint 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 floatingpoint routines before and convinced Gates and Allen that he was capable of writing the Altair BASIC floatingpoint code.^{[9]} At the time, while IBM had introduced their own programs, there was no standard for floatingpoint 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 MerrillOldham 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.^{[17]}^{[18]} The BASIC port for the 6502 CPU, such as used in the Commodore PET, took up more space due to the lower code density of the 6502. Because of this it would likely not fit in a single ROM chip together with the machinespecific input and output code. Since an extra chip was necessary, extra space was available, and this was used in part to extend the floatingpoint format from 32 to 40 bits.^{[8]} This extended format was not only provided by Commodore BASIC 1 & 2, but was also supported by Applesoft BASIC I & II since version 1.1 (1977), KIM1 BASIC since version 1.1a (1977), and MicroTAN BASIC since version 2b (1980).^{[8]} Not long afterwards, the Z80 ports, such as Level II BASIC for the TRS80 (1978), introduced the 64bit, doubleprecision format as a separate data type from 32bit, singleprecision.^{[19]}^{[20]}^{[21]} Microsoft used the same floatingpoint formats in their implementation of Fortran^{[22]} and for their macro assembler MASM,^{[23]} although their spreadsheet Multiplan^{[24]}^{[25]} and their COBOL implementation used binarycoded decimal (BCD) floating point.^{[26]} Even so, for a while MBF became the de facto floatingpoint format on home computers, to the point where people still occasionally encounter legacy files and file formats using it.^{[27]}^{[28]}^{[29]}^{[30]}^{[31]}^{[32]}
In a parallel development, Intel had started the development of a floatingpoint coprocessor in 1976.^{[33]}^{[34]} William Morton Kahan, as a consultant to Intel, suggested that Intel use the floating point of Digital Equipment Corporation's (DEC) VAX. The first VAX, the VAX11/780 had just come out in late 1977, and its floating point was highly regarded. VAX's floatingpoint formats differed from MBF only in that it had the sign in the most significant bit.^{[35]}^{[36]} However, seeking to market their chip to the broadest possible market, Kahan was asked to draw up specifications.^{[33]} When rumours of Intel's new chip reached its competitors, they started a standardization effort, called IEEE 754, to prevent Intel from gaining too much ground. As an 8bit exponent was not wide enough for some operations desired for doubleprecision numbers, e.g. to store the product of two 32bit numbers,^{[1]} Intel's proposal and a counterproposal from DEC used 11 bits, like the timetested 60bit floatingpoint format of the CDC 6600 from 1965.^{[34]}^{[37]}^{[38]} Kahan's proposal also provided for infinities, which are useful when dealing with divisionbyzero conditions; notanumber values, which are useful when dealing with invalid operations; denormal numbers, which help mitigate problems caused by underflow;^{[37]}^{[39]}^{[40]} and a better balanced exponent bias, which could help avoid overflow and underflow when taking the reciprocal of a number.^{[41]}^{[42]}
By the time QuickBASIC 4.00 was released,^{[when?]} the IEEE 754 standard had become widely adopted—for example, it was incorporated into Intel's 387 coprocessor and every x86 processor from the 486 on. QuickBASIC versions 4.0 and 4.5 use IEEE 754 floatingpoint variables by default, but (at least in version 4.5) there is a commandline option /MBF for the IDE and the compiler that switches from IEEE to MBF floatingpoint numbers, to support earlierwritten programs that rely on details of the MBF data formats. Visual Basic also uses the IEEE 754 format instead of MBF.
MBF numbers consist of an 8bit base2 exponent, a sign bit (positive mantissa: s = 0; negative mantissa: s = 1) and a 23,^{[43]}^{[8]} 31^{[8]} or 55bit^{[43]} mantissa of the significand. There is always a 1bit implied to the left of the explicit mantissa, and the radix point is located before this assumed bit. The exponent is encoded with a bias of 128^{[citation needed]}, so that exponents −127…−1^{[citation needed]} are represented by x = 1…127 (01h…7Fh)^{[citation needed]}, exponents 0…127^{[citation needed]} are represented by x = 128…255 (80h…FFh)^{[citation needed]}, with a special case for x = 0 (00h) representing the whole number being zero.
The MBF doubleprecision format provides less scale than the IEEE 754 format, and although the format itself provides almost one extra decimal digit of precision, in practice the stored values are less accurate because IEEE calculations use 80bit intermediate results, and MBF doesn't.^{[1]}^{[3]}^{[43]}^{[44]} Unlike IEEE floating point, MBF doesn't support denormal numbers, infinities or NaNs.^{[45]}
MBF singleprecision format (32 bits, "6digit BASIC"):^{[43]}^{[8]}
Exponent  Sign  Significand 

8 bits, bit 31–24 
1 bit, bit 23 
23 bits, bit 22–0 
xxxxxxxx  s  mmmmmmmmmmmmmmmmmmmmmmm 
MBF extendedprecision format (40 bits, "9digit BASIC"):^{[8]}
Exponent  Sign  Significand 

8 bits, bit 39–32 
1 bit, bit 31 
31 bits, bit 30–0 
xxxxxxxx  s  mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm 
MBF doubleprecision 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 