Menu

Reference / Manticore\Ds

Float64Array

finalclass
final class Float64Array<T> extends FloatTypedArray

64-bit floats (8 bytes per element), IEEE-754 binary64: the same precision as a PHP float, so every value round-trips exactly.

Type parameters

T
= float @extends FloatTypedArray<T>

Example

use Manticore\Ds\Float32Array;
use Manticore\Ds\Float64Array;

$f = new Float64Array(2);
$f[0] = 0.1;
$f[1] = 3;                      // an int is converted
echo $f[0], ' ', $f[1], ' ', $f->sum(), "\n";

$narrow = new Float32Array(1);
$narrow[0] = 0.1;               // rounded to binary32
var_dump($narrow[0]);

var_dump($f->equals(Float64Array::fromArray([0.1, 3.0])));

Output

0.1 3 3.1
float(0.10000000149011612)
bool(true)

View source