On 22 August 2007 11:40, Andrew Pinski wrote:
> On 8/22/07, Dave Korn <[EMAIL PROTECTED]> wrote:
>> float InvSqrt (float x){
>> float xhalf = 0.5f*x;
>> int i = *(int*)&x;
>
> You are violating C/C++ aliasing rules here anyways.
>
>> i = 0x5f3759df - (i>>1);
>> x = *(float*)&i;
>
> Likewise.
>
> So I guess you like to depend on undefined code :).
Well, I like to think that I could cast the address to unsigned char*, memcpy
a bunch of them to the address of an int, then dereference the int and the
compiler would realise it was a no-op and optimise it away, but I doubt thatt
would actually happen...
cheers,
DaveK
--
Can't think of a witty .sigline today....