Bug #74451 [Fbk->NoF]: Sine values exceed 1
| From: | php-bugs at lists dot php dot net | Date: | Sun, 30 Apr 2017 04:22:33 +0000 |
| Subject: | Bug #74451 [Fbk->NoF]: Sine values exceed 1 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-208861@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74451&edit=1
ID: 74451
Updated by: php-bugs@lists.php.net
Reported by: m_sun at mail dot ru
Summary: Sine values exceed 1
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: Math related
Operating System: Alpine Linux
PHP Version: 5.6.30
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2017-04-16 22:18:19] m_sun at mail dot ru
PS: Seems like this is not a hardware issue, neither musl libc. Result is always the same even after
restarting php5-fpm. Alpine Linux uses grsec patch and loads binaries in arbitrary memory addresses
on each start.
I additionally posted a bug report on Alpine Linux board.
------------------------------------------------------------------------
[2017-04-16 22:07:25] m_sun at mail dot ru
Standard libc sin() works just fine. Bc also gives correct result on the machine in question:
echo 's(60)' | bc -l
But problem with php is still there:
php5 -r 'echo sin(60) . "\n";'
output is 19880855899899
Right now I use a workaround
echo sin(fmod(60, M_PI * 2));
------------------------------------------------------------------------
[2017-04-16 18:21:53] requinix@php.net
Does a simple
#include <math.h>
#include <stdio.h>
void main(void) { printf("%f\n", sin(60.0)); }
work correctly?
------------------------------------------------------------------------
[2017-04-16 11:16:53] m_sun at mail dot ru
You are right: the problem can't be reproduced in a testbed for PHP 5.6.30. I suppose there is
a problem in realization (librariess are compiled against musl libc on Alpine Linux) or a hardware
issue...
Thank you danack at php dot com
<?php
$start = 60.0;
$a = $start;
$da = 0.1;
$target = M_PI + $start;
$tab = array();
while ($a < $target) {
$item['rad'] = $a;
$item['deg'] = number_format(rad2deg($a), 2);
$item['sin'] = sin($a);
$item['cos'] = cos($a);
$tab[] = $item;
$a += $da;
}
?>
<style>
table, td, th {
border-collapse:collapse;
border:1px solid #000;
}
</style>
<table>
<tr>
<th>Radian</th>
<th>Degrees</th>
<th>Sin</th>
<th>Cos</th>
</tr>
<?php foreach($tab as $item): ?>
<tr>
<td><?= $item['rad'] ?></td>
<td><?= $item['deg'] ?></td>
<td><?= $item['sin'] ?></td>
<td><?= $item['cos'] ?></td>
</tr>
<?php endforeach; ?>
</table>
------------------------------------------------------------------------
[2017-04-16 10:17:18] danack@php.net
I can't reproduce what you're reporting: https://3v4l.org/fnd5R
Please can you provide an actual runnable reproduce script.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=74451
--
Edit this bug report at https://bugs.php.net/bug.php?id=74451&edit=1