Hacker News new | past | comments | ask | show | jobs | submit login

I'm referring to the float registers, not arbitrary precision. So, 'math.pi' essentially.

You probably already know this, I'll apologise in advance - My understanding is you can only get accurate values of a value smaller than unity on a float if it is a sum of perfect powers of 1/2 (ie. the denominator is a perfect power of two). Therefore any reciprocal of an odd number will get an error (bar the first term, which is 1) since odd numbers don't fall into the above category (except for 1).

I tried using this series years ago to calculate pi. It was a total disaster, the final value was way off.

Edit: 'sum of'




Right, yes, for continued fractions / convergent series, floats are almost certainly going to be a complete disaster whereas if only integer division is involved, as is the case with this series, then arbitrary precision rationals are going to be exact, and often sufficiently performant for most such series for results up to about 15 decimal digits or so.

Damian demonstrates this difference between using floats and arbitrary precision rationals when he shows code for computing Bernoulli numbers in his "On The Shoulders Of Giants" presentation.[0]

(Btw, if you care about programming and appreciate a combination of total technical and geek mastery with standup comic delivery, the whole thing is like watching a great movie, whether you watch it from the "start" at the 5 minute mark, or skip forward to the 45 minute mark for the 15 minute Quantum Computing For Beginners section.)

[0] https://www.youtube.com/watch?v=Nq2HkAYbG5o#t=11m09s


It really is a great presentation. I sent Damian an email after watching it and he was also extremely approachable and took the time to answer my questions and talk about the future of raku (at that time Perl 6).


Thank you for the link, I might start watching at the beginning.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: