help-octave
[Top][All Lists]

## Re: If pi is so accurate why it's not producing that accurate result.

 From: Nicholas Jankowski Subject: Re: If pi is so accurate why it's not producing that accurate result. Date: Fri, 23 Mar 2018 15:57:45 -0400

On Fri, Mar 23, 2018 at 3:44 PM, Nicholas Jankowski wrote:
On Fri, Mar 23, 2018 at 3:16 PM, Dildar Sk wrote:
Sorry,
I know it's very hard to deal with floating point arithmetic.
But I am just asking why tan(pi/2) is not close to infinity.Though there
in Octave max is 10^308 but it producing 10^17 something.
And I wonder how pi is so accurate then!!

you are getting into some of the subtle details of floating point arithmetic. 10^308 is on the order of the largest normalized real number. the 10^17 deals with relative precision.  see the following:

https://www.maths.unsw.edu.au/sites/default/files/MatlabSelfPaced/lesson2/MatlabLesson2_Constants.html

perhaps a slightly more complete explanation:
https://www.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html