php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login go to bug id or search bugs for
Bug #31803 Submitted: Erro in Cos function 2005-02-02 04:16 UTC 2008-03-27 14:22 UTC thiago_mata at yahoo dot com dot br Not a bug Math related 4.3.10 Windows XP No None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !

[2005-02-02 04:16 UTC] 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

```

## History

```Floating point values have a limited precision. Hence a value might