# getid3_lib::BigEndian2Float

## #Summery Summery

ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic

## #Syntax Syntax

getid3_lib::BigEndian2Float( string \$byteword )

\$byteword

(Required)

(float|false)

## #Source Source

```		\$bitword = self::BigEndian2Bin(\$byteword);
if (!\$bitword) {
return 0;
}
\$signbit = \$bitword[0];
\$floatvalue = 0;
\$exponentbits = 0;
\$fractionbits = 0;

switch (strlen(\$byteword) * 8) {
case 32:
\$exponentbits = 8;
\$fractionbits = 23;
break;

case 64:
\$exponentbits = 11;
\$fractionbits = 52;
break;

case 80:
// 80-bit Apple SANE format
// http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
\$exponentstring = substr(\$bitword, 1, 15);
\$isnormalized = intval(\$bitword[16]);
\$fractionstring = substr(\$bitword, 17, 63);
\$exponent = pow(2, self::Bin2Dec(\$exponentstring) - 16383);
\$fraction = \$isnormalized + self::DecimalBinary2Float(\$fractionstring);
\$floatvalue = \$exponent * \$fraction;
if (\$signbit == '1') {
\$floatvalue *= -1;
}
return \$floatvalue;

default:
return false;
}
\$exponentstring = substr(\$bitword, 1, \$exponentbits);
\$fractionstring = substr(\$bitword, \$exponentbits + 1, \$fractionbits);
\$exponent = self::Bin2Dec(\$exponentstring);
\$fraction = self::Bin2Dec(\$fractionstring);

if ((\$exponent == (pow(2, \$exponentbits) - 1)) && (\$fraction != 0)) {
// Not a Number
\$floatvalue = false;
} elseif ((\$exponent == (pow(2, \$exponentbits) - 1)) && (\$fraction == 0)) {
if (\$signbit == '1') {
\$floatvalue = '-infinity';
} else {
\$floatvalue = '+infinity';
}
} elseif ((\$exponent == 0) && (\$fraction == 0)) {
if (\$signbit == '1') {
\$floatvalue = -0;
} else {
\$floatvalue = 0;
}
\$floatvalue = (\$signbit ? 0 : -0);
} elseif ((\$exponent == 0) && (\$fraction != 0)) {
// These are 'unnormalized' values
\$floatvalue = pow(2, (-1 * (pow(2, \$exponentbits - 1) - 2))) * self::DecimalBinary2Float(\$fractionstring);
if (\$signbit == '1') {
\$floatvalue *= -1;
}
} elseif (\$exponent != 0) {
\$floatvalue = pow(2, (\$exponent - (pow(2, \$exponentbits - 1) - 1))) * (1 + self::DecimalBinary2Float(\$fractionstring));
if (\$signbit == '1') {
\$floatvalue *= -1;
}
}
return (float) \$floatvalue;
}

/**
* @param string \$byteword
```