## digitalmars.D.learn - std.math module

• greatsam4sure (6/6) Aug 06 import std.math;
• sarn (10/16) Aug 06 That's just floating point maths for you. You're not putting
• Nicholas Wilson (3/9) Aug 06 in addition to what sarn said, tan(3pi/4) is a pole, not
• greatsam4sure (3/14) Aug 07 Thanks for the help. I will appreciate any resources for further
greatsam4sure <greatsam4sure gmail.com> writes:
```import std.math;
import std.stdio;

cos(90*PI/180) = -2.7e-20 instead of zero. I will appreciate any

tan(90*PI/180) = -3.689e+19 instead of infinity. What is the best
way to use this module
```
Aug 06
sarn <sarn theartofmachinery.com> writes:
```On Sunday, 6 August 2017 at 23:33:26 UTC, greatsam4sure wrote:
import std.math;
import std.stdio;

cos(90*PI/180) = -2.7e-20 instead of zero. I will appreciate

tan(90*PI/180) = -3.689e+19 instead of infinity. What is the
best way to use this module

That's just floating point maths for you.  You're not putting
exactly pi/2 into cos, just a good floating point approximation.
What you're getting out isn't exactly 0, either, just a good
floating point approximation.  (-2.7e-20 is really, really small.)

Here's a good talk from DConf 2016:

If you need exact maths, you'll need a symbolic manipulation
library (never used one in D, but there was a discussion recently
don't need this for most practical applications, though.
```
Aug 06
Nicholas Wilson <iamthewilsonator hotmail.com> writes:
```On Sunday, 6 August 2017 at 23:33:26 UTC, greatsam4sure wrote:
import std.math;
import std.stdio;

cos(90*PI/180) = -2.7e-20 instead of zero. I will appreciate

tan(90*PI/180) = -3.689e+19 instead of infinity. What is the
best way to use this module

in addition to what sarn said, tan(3pi/4) is a pole, not
infinity. the mean of the left and right hand limits is 0
```
Aug 06
greatsam4sure <greatsam4sure gmail.com> writes:
```On Monday, 7 August 2017 at 04:47:56 UTC, Nicholas Wilson wrote:
On Sunday, 6 August 2017 at 23:33:26 UTC, greatsam4sure wrote:
import std.math;
import std.stdio;

cos(90*PI/180) = -2.7e-20 instead of zero. I will appreciate

tan(90*PI/180) = -3.689e+19 instead of infinity. What is the
best way to use this module

in addition to what sarn said, tan(3pi/4) is a pole, not
infinity. the mean of the left and right hand limits is 0

Thanks for the help. I will appreciate any resources for further