Re: [GD-General] The joy of type aliasing and C
Brought to you by:
vexxed72
From: Alen L. <ale...@cr...> - 2003-12-29 11:30:58
|
> Yep: > int _fpclass(double); Yes of course. But, the purist argument was "this is not portable". Heck, I think checking out the bits of *(int*)&f is much more portable than _fpclass(). ;) > BTW I tend to write this: > > int x = ( int & ) f; > > instead of: > > int x = * ( int * ) &f; > > Any known difference ? AFAIK, references are just syntactic sugar, so I see no reason why there should be a semantic difference. But then again, recasting across a char* before casting to int* shouldn't make a difference either (logically), but according to the standard it does. :/ Anyway, using something like: inline int &FloatAsInt(float &f) { return (int&)f; } should allow you to fix it by putting a lot of #ifs in there if you have problems with particular compiler(s) later. -- Alen |