RE: [GD-General] The joy of type aliasing and C
Brought to you by:
vexxed72
|
From: Crosbie F. <cr...@cy...> - 2003-12-30 09:49:40
|
> From: Alen Ladavac > > Didn't see the whole thing, so perhaps this is a stupid > question, but... is > there any particular reason that they mention an lvalue? Because, as I > understand, we are accessing the stored value of a float > through an rvalue of > type int, not lvalue of type int. (I mean, it could have just > as well been > (const int*), wouldn't make a difference.) int x = ( int & ) f; int x = * ( int * ) &f; In both cases 'f' is an lvalue (in this example). Perhaps one might avoid aliasing if one declared f as register or as volatile, but it's pretty tricky to get the binary representation of a float without going via an lvalue of some sort. Which then prompts the questions: 1) Is it possible to convert a float to its native binary representation without going via an lvalue (not even indirectly)? 2) What is the most portable way (that avoids risk of alias optimisation) of getting a float into binary representation, in native form and/or a particular standard form (IEEE, etc.)? |