NAME

val - convert from Microsoft binary format

SYNOPSIS

#include <basic/string.h>

float cvsmb(s)
struct string *s;

double cvdmb(s)
struct string *s;

struct string mksmbS(f)
float f;

struct string mkdmbS(d)
double d;

DESCRIPTION

These functions convert floating point format data between the so-called Microsoft Binary Format and the more socially acceptable ANSI/IEEE Standard 754/1985.  These functions represent the archaic Format as strings and represent the more modern Standard as the native floating point format.  Thus the system in use, itself, is presumed to be using the Standard, evidently converting data from an outmoded system. 

The Microsoft Binary Format is arranged with more significant bits stored in bytes with higher addresses and an exponent bias of 129.  The 32 bit version contains, from least to most significant bits: 23 mantissa, one sign and 8 exponent.  The 64 bit version contains: 55 mantissa, one sign and 8 exponent. 

The ANSI/IEEE Standard 754/1985 is arranged in the native byte order.  The 32 bit version contains, from least to most significant bits: 23 mantissa, 8 exponent and one sign, with an exponent bias of 127.  The 64 bit version contains: 52 mantissa, 11 exponent and one sign, with an exponent bias of 1023. 

In any case, any value with an exponent field of zero, or an exponent out of the range of the target format, is interpreted as a zero value and returned with all bits off.  A numberís sign bit is one if negative and otherwise identical to its absolute value.  Excepting of course zero, the mantissa is a fraction of one, plus an implicit whole one. 

Cvsmb returns a float value in the modern Standard converted from the first four bytes of the string pointed to by s in the archaic Format. 

Cvdmb returns a double value in the modern Standard converted from the first eight bytes of the string pointed to by s in the archaic Format.  The mantissa is truncated by three bits. 

MksmbS returns a four byte string in the archaic Format converted from the float value f in the modern Standard. 

MkdmbS returns an eight byte string in the archaic Format converted from the double value d in the modern Standard.  The mantissa is extended by three bits, with a value of Ĺ the original least significant bit. 

SEE ALSO

string(inc)
cvsmbf, cvdmbf(func), mksmbf$, mkdmbf$(func)

DIAGNOSTICS

Error 5 (Illegal function call) is generated by cvsmb if s has fewer than four bytes and by cvdmb if s has fewer than eight bytes. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber