php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51941 sin() and cos() functions return wrong values
Submitted: 2010-05-28 08:59 UTC Modified: 2011-08-26 21:42 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: veyder at gmail dot com Assigned: pajoye (profile)
Status: Wont fix Package: Math related
PHP Version: 5.3.2 OS: Windows XP/Windows 7
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-05-28 08:59 UTC] veyder at gmail dot com
Description:
------------
For very large values of $x (9.2233720368548E+18 and more), sin($x) and cos($x) simply return $x

Test script:
---------------
$x = 9.2233720368547E+18;
var_dump(sin($x));
var_dump(cos($x));

$x = 9.2233720368548E+18;
var_dump(sin($x));
var_dump(cos($x));

$x = 9.2233720368547E+22;
var_dump(sin($x));
var_dump(cos($x));

$x = 9.2233720368547E+5;
var_dump(sin($x));
var_dump(cos($x));

Expected result:
----------------
float(0.70730241295515)
float(0.70691109527848)
float(9.2233720368548E+18)
float(9.2233720368548E+18)
float(9.2233720368547E+22)
float(9.2233720368547E+22)
float(-0.15745275115961)
float(-0.98752652174626)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-28 23:40 UTC] pajoye@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: pajoye
 [2010-05-28 23:40 UTC] pajoye@php.net
And what do you get?

Which version of php do you? VC6 or VC9?
 [2010-05-31 05:14 UTC] aharvey@php.net
For the record, I can't reproduce this on 64-bit Linux or OS X, so this looks like it's Windows specific.
 [2011-08-26 19:01 UTC] v-mafick at microsoft dot com
Thank you for reporting this.

This bug is reproducable on VC6, but this bug is not reproducable on VC9.

Moving forward, PHP is only supported on VC9.

Please upgrade to a PHP binary based on VC9 (the ZIP file you download will have 'vc9' in the filename).
 [2011-08-26 21:42 UTC] pajoye@php.net
-Status: Feedback +Status: Wont fix
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 07:01:25 2019 UTC