News for hackers. Stuff that matters.
Re:Magical Square Root Implementation In Quake III by Carmack by boroadlkjq on Friday February 21, 2014 @11:11AM (#7277586)
Are there other weird number hacks like this one?
Re:Magical Square Root Implementation In Quake III by Carmack by matwood on Friday February 21, 2014 @11:22AM (#7277648)
Look at the hashCode() implementations in http://grepcode.com/file/repository.grepcode.com/java/root/j...

For example:

public static int hashCode(double a[])

{

if (a == null) return 0;

        int result = 1;
        for (double element : a) {
            long bits = Double.doubleToLongBits(element);
            result = 31 * result + (int)(bits ^ (bits >>> 32));
        }
        return result;
    }
Re:Magical Square Root Implementation In Quake III by Carmack by snotrockets on Friday February 21, 2014 @01:45PM (#7278580)
Why is this weird? It's the textbook method for doing hashes.
Re:Magical Square Root Implementation In Quake III by Carmack by matwood on Friday February 21, 2014 @05:15PM (#7279822)
It is textbook, but the poster asked for seemingly random numbers in code. Based on all the places the invsqrt method has popped up, it also was a textbook method for doing it quickly.