Latest UploadsPlatdude SpottingJayenkaiNom nom nomJayenkaiRainbow TroutPakzKing SalmonPakzSnookerJayenkaiYou've ... o have youJayenkai
 Code Snippets > Variables ( Created 29 June 2009 | Last Edited 29 June 2009)

 Fast inverse square root by Phoenix | Rating 100% Written inMonkey Found this while browsing about the net, and I thought it could be useful (or at least an interesting read). Lengthy explanation, for the mathematically inclined. float InvSqrt(float x){ float xhalf = 0.5f * x; int i = *(int*)&x; // store floating-point bits in integer i = 0x5f3759d5 - (i >> 1); // initial guess for Newton's method x = *(float*)&i; // convert new bits into float x = x*(1.5f - xhalf*x*x); // One round of Newton's method return x; } -->

Posted : Monday, 29 June 2009, 16:19
Scherererer

Vote : 5
This is really interesting; I skimmed through the research paper, probably give it a closer look a bit later. I've covered Newton's method in the recent pass; probably one of the most important computational approximation methods in existence, but it was very interesting reading how they derived that constant. I'll need to remember this function so I can use it later projects.

Thanks!

-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 640|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
 Latest PostsLaptop Aaargh... Jayenkai Sun 15:03 Technology on Planes therevillsgames Sat 17:00 London Car/Stab Incident steve_ancell Sat 12:10 A New Korg Gadget! Jayenkai Sat 04:53 GamerBlock rockford Fri 16:51 Happy Birthday, Spinal Jayenkai Fri 08:40 Watch Switch - Fitbit Blaze rockford Fri 03:52 Happy Birthday Evil Roy Ferguson rockford Wed 16:21 Spinal's Return to Android Jayenkai Tue 13:41 AGameAWeek : 2017 - Part One Jayenkai Tue 08:10 More

 Latest Items Blog : My Arduino experience.steve_ancell Fri 13:45 Snippet : Skylinesspinal Fri 06:13 Showcase : Infinitronrychan Tue 03:02 Dev-Diary : PS2 to N64 Adapterspinal Sun 10:49 Link : Vector Tutorials/Help page.Pakz Thu 23:00 Blog : mini projectspinal Sun 10:13 Showcase : Blockman ReturnsJayenkai Fri 03:04 Snippet : Wall Tracing on Random Maps (rpg)rskgames Wed 22:48 Snippet : Path FollowingPakz Mon 16:25 Snippet : Flowers (Jan 2017)Kuron Thu 01:13 Showcase : Clusters of Hextherevillsgames Mon 15:01 Article : Maths 101 - Episode 1: Basic Trigonometryshroom_monk Sun 14:07 Article : Maths 101 - Episode 5: Line Intersectionshroom_monk Sun 14:02 Dev-Diary : Normals and Dot productsPakz Sat 20:37 Pets : Molly On The CouchJayenkai Thu 04:32More

Who's Online
Pakz
Sun, at 16:37
shroom_monk
Sun, at 16:11
Jayenkai
Sun, at 15:59
spinal
Sun, at 13:37
rockford
Sun, at 13:05
rychan
Sun, at 12:17
Andy_A
Sun, at 11:41
rskgames
Sun, at 10:56
HoboBen
Sun, at 10:26