getid3_lib::Float2BinaryDecimal

Advertisement

Syntax Syntax

getid3_lib::Float2BinaryDecimal( float $floatvalue )

Parameters Parameters

$floatvalue

(Required)

Return Return

(string)

Source Source

File: wp-includes/ID3/getid3.lib.php

	public static function Float2BinaryDecimal($floatvalue) {
		$maxbits = 128; // to how many bits of precision should the calculations be taken?
		$intpart   = self::trunc($floatvalue);
		$floatpart = abs($floatvalue - $intpart);
		$pointbitstring = '';
		while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
			$floatpart *= 2;
			$pointbitstring .= (string) self::trunc($floatpart);
			$floatpart -= self::trunc($floatpart);
		}
		$binarypointnumber = decbin($intpart).'.'.$pointbitstring;
		return $binarypointnumber;
	}

Advertisement

Advertisement

Leave a Reply