Alexey Beshenov on Sat, 19 Sep 2020 07:03:35 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Fortran compatibility


Hello,

I think it's slightly off-topic :-)

There's a Wikipedia article with detailed explanations:
https://en.wikipedia.org/wiki/Fast_inverse_square_root

--
A


El vie., 18 sept. 2020 a las 23:23, Another Loco y ya
(<0xccaaffee@gmail.com>) escribió:
>
> Dear Bill, and friends here, have you ever seen it? this ( C? ) code:
>
>     float InvSqrt (float x){
>      float xhalf = 0.5f*x;
>      int i = *(int*)&x;
>      i = 0x5f3759df - (i>>1);
>      x = *(float*)&i;
>      x = x*(1.5f - xhalf*x*x);
>      return x;
>     }
>
> At some point of history, it is supposed to have been used widely for
> calculating the 1 / sqrt(x).
>
> i still wonder how it works, and inspired by the FORTRAN question you
> just solved, i thought this would be worthy of some contemplation...
> perhaps later. (At least me) Not hurried.
>
> :-) Merci