I have a file called test.pfd which contains large amounts data (20 samples per second) and around 112 seconds, so roughly 2240 data units.
I want to produce a a graph, so need to generate the xaxis time which is 0.05 seconds (20 samples per second) intervals
This code produces a result like after several loops
46.1
46.15
46.2
46.25
46.3
46.35
46.4
46.449999999999
46.499999999999
46.549999999999
46.599999999999
46.649999999999
46.699999999999
46.749999999999
46.799999999999
$handle = @fopen("test.pfd", "r");
$Altitude ="";
$SPSn = 0.00;
$SPSt = "0.00";
$ImportStart = "False";
if ($handle) {
while (!feof($handle)) {
$buffer = trim(fgets($handle, 4096));
if ($buffer == "**!!Data:") {
$ImportStart = "True";
}
if ($ImportStart == "True") {
$Altitude .= ",".$buffer;
$SPSn = $SPSn + 0.05;
echo $SPSn."<br>";
}
}
}
I have now changed the line to read $SPSn = round($SPSn, 2) + 0.05; and all is fine with the rounding. but why?
Thanks