RE: The joy of type aliasing and C

"Crosbie Fitch" <[email protected]>
Newsgroups gmane.games.devel.general
Message-ID <004101c3ceba$48d73c50$2500a8c0@blue500>
> 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.)?




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Gamedevlists-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=557
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.