News for hackers. Stuff that matters.
Re:"The worst algorithm in the world?" by robinhouston on Wednesday May 11, 2011 @06:47PM (#2538715)
Actually I think that roughly was my point. :-)

You can’t get an exact answer in general by using fixed-size floating-point numbers, as your pseudocode does. The number of bits of precision you need to get an exact answer is going to depend on the input value, presumably linearly.

Re:"The worst algorithm in the world?" by kenjackson on Wednesday May 11, 2011 @06:53PM (#2538735)
When you round you'll always get the exact integer answer, even using the precision of the golden ratio I gave in the code.
Re:"The worst algorithm in the world?" by robinhouston on Wednesday May 11, 2011 @07:08PM (#2538782)
That’s really not true. You don’t have to take my word for it: try it with fib(1000), say.

The answer should be:

  43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875
Re:"The worst algorithm in the world?" by kenjackson on Wednesday May 11, 2011 @10:26PM (#2539272)
Oh, the old n=1000 trick. Well played.