Saturday, September 10, 2011

the fix for OSX

I had to change the square root test to:


if ((int)(sqrt(n) * (int)sqrt(n) == n))

This takes the square root of n and truncates everything after the decimal via cast to integer before multiplying against itself. There are many intricacies of number types that fall into the category of "not really important until it suddenly is".

No comments:

Post a Comment