#31803 [Opn->Bgs]: Erro in Cos function
| From: | derick@php.net | Date: | Wed, 02 Feb 2005 07:39:38 +0000 |
| Subject: | #31803 [Opn->Bgs]: Erro in Cos function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-73242@lists.php.net to get a copy of this message | ||
ID: 31803
Updated by: derick@php.net
Reported By: thiago_mata at yahoo dot com dot br
-Status: Open
+Status: Bogus
Bug Type: Safe Mode/open_basedir
Operating System: Windows XP
PHP Version: 4.3.10
New Comment:
Floating point values have a limited precision. Hence a value might
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly
printing it without any mathematical operations.
Thank you for your interest in PHP.
.
Previous Comments:
------------------------------------------------------------------------
[2005-02-02 04:16:33] thiago_mata at yahoo dot com dot br
Description:
------------
The funcion cos it is not return the espected result. While the sin it
is ok.
Reproduce code:
---------------
$Angulo = Pi()/2;
print "cos(Angulo) = ".cos($Angulo)."<BR>\n";
print "cos(Pi/2) = ".cos(Pi()/2)."<BR>\n";
print "Angulo = $Angulo <br>\n";
$cos = sqrt(1 - sin($Angulo)*sin($Angulo));
print "Coseno = ".cos($Angulo)."<br>\n Cos =
".$cos."<BR>\n";
print "Seno = ".sin($Angulo)."<BR>\n";
Expected result:
----------------
cos(Angulo) = 0
cos(Pi/2) = 0
Angulo = 1.5707963267949
Coseno = 0
Cos = 0
Seno = 1
Actual result:
--------------
cos(Angulo) = 6.1230317691119E-017
cos(Pi/2) = 6.1230317691119E-017
Angulo = 1.5707963267949
Coseno = 6.1230317691119E-017
Cos = 0
Seno = 1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31803&edit=1