Kelvin Primo Kelvin Primo - 1 month ago 14
PHP Question

have a better method to run this php?

Have another way to run this number generator?
I want all the zeros. for exampe

0.00000000000000000000000009949
instead
9.949E-26


my code:

<?php
ini_set('max_execution_time', 3000000000);
$myfile = fopen("numbers.txt", "w") or die("Unable to open file!");
for ($i = 0; $i <= 1; $i+= 0.000000000000000000000000000001) {
$txt = $i.";";
fwrite($myfile, $txt);
}
fclose($myfile);
?>

Answer

Look at number_format

for ($i = 0; $i <= 1; $i += 0.000000000000000000000000000001) {
    $txt = number_format($i, 30) . ";";
    fwrite($myfile, $txt);
}

This will give you all the zeros or even more, if you like. At least up to some precision, see Wikipedia - IEEE floating point for details.