if ($floatvalue >= 0
) { $signbit = '0';
} else { $signbit = '1';
} $normalizedbinary = self::
NormalizeBinaryPoint(self::
Float2BinaryDecimal($floatvalue),
$fractionbits);
$biasedexponent =
pow(2,
$exponentbits - 1
) - 1 +
$normalizedbinary['exponent'
]; // (127 or 1023) +/- exponent
$exponentbitstring =
str_pad(decbin($biasedexponent),
$exponentbits, '0', STR_PAD_LEFT
);
$fractionbitstring =
str_pad(substr($normalizedbinary['normalized'
], 2
),
$fractionbits, '0', STR_PAD_RIGHT
);
return self::
BigEndian2String(self::
Bin2Dec($signbit.
$exponentbitstring.
$fractionbitstring),
$bits % 8, false
);
} /**
* @param string $byteword
*
* @return float|false
*/
public static function LittleEndian2Float($byteword) { return self::
BigEndian2Float(strrev($byteword));
}