Skip to main content
GameDev.net gamedev.net
🔒 Locked

something to explain

Started by Dave007 Jan 3, 2001 at 12:07 PM 0 replies 450+ views
Original Post
Dave007
Dave007
Hi! I need to explain this code. It''s taken from glVelocity fast code library. But I don''t understand anything of this. It might do rational sqrt. Thnx for help.
__inline float RSqrt(float number)
{
	long i;
	float x2, y;
	const float threehalfs = 1.5f;

	x2 = number * 0.5f;
	y  = number;
	i  = * (long *) &y						i  = 0x5f3759df - (i >> 1);             
	y  = * (float *) &i
	y  = y * (threehalfs - (x2 * y * y));   

	return y;
}
 
Dave007 dave007@volny.cz
--------Dave[ Math Studio ] A Computer Algebra System
Shannon Barber
Shannon Barber
What''s the difference between a square root & a rational square root?
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.