Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Fast C++ Code Library

  • 02-12-2002 03:42PM
    #1
    Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭


    I found this code on a Korean site last night. Seems like some very handy stuff (especially for graphics/games - see the Quake 3 reciprocal square root below, mmm...) - although I haven't actually used any of these yet, so use at your own risk.

    (It's too big to post up here... FastCodeLibrary.h)

    Example:
    [PHP]// Fast reciprocal square root (Quake 3 game code)
    __inline float RSqrt(float number)
    {
    long i;
    float x2, y;
    const float threehalfs = 1.5f;

    x2 = number * 0.5f;
    y = number;
    i = * (long *) &y; // evil floating point bit level hacking
    i = 0x5f3759df - (i >> 1); // what the f*ck?
    y = * (float *) &i;
    y = y * (threehalfs - (x2 * y * y)); // 1st iteration

    return y;
    }[/PHP]


Comments

  • Registered Users, Registered Users 2 Posts: 95 ✭✭Mr.StRiPe


    Nice one keith I was actuall looking for code like that. Hows the postgrad going?


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    It's goin great except for Charlie 'Fuckwit' McCreevy cutting practically the whole project equipment budget for the next year, along with a number of other projects. How the hell am I meant to build a CAVE with no bloody equipment, eh?!


Advertisement