Bug #74451 [Fbk]: Sine values exceed 1

From: Date: Sun, 16 Apr 2017 18:21:54 +0000
Subject: Bug #74451 [Fbk]: Sine values exceed 1
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208603@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: requinix@php.net Reported by: m_sun at mail dot ru Summary: Sine values exceed 1 Status: Feedback Type: Bug Package: Math related Operating System: Alpine Linux PHP Version: 5.6.30 Block user comment: N Private report: N New Comment: Does a simple #include <math.h> #include <stdio.h> void main(void) { printf("%f\n", sin(60.0)); } work correctly? Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2017-04-16 03:39:25] m_sun at mail dot ru Description: ------------ Absolute values of sine and cosine functions may somehow exceed 1 when argument is more then 2 * pi Test script: --------------- $sin = sin(60.0); // $sin contains 19880855899899 now $sin = sin (fmod (60.0, M_PI * 2)); // Gives correct result now Actual result: -------------- Radian Degrees Sin Cos 60 3,437.75 19880855899899 -84637265064481 60.1 3,443.48 20318846900770 -86648047391510 60.2 3,449.21 20765725188326 -88703090857283 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74451&edit=1

« previous php.bugs (#208603) next »