Re: The joy of type aliasing and C

Eero Pajarre <[email protected]>
Newsgroups gmane.games.devel.general
Message-ID <[email protected]>
Alen Ladavac wrote:


> Generally, trying to look at a float as if it's some kind of a black box that
> stores real numbers, is kinda silly. You have to be aware of its internal
> representation, or you can't work with it (without getting yourself into
> various precision losses, etc). And once you are aware, you should be able to
> access it. But I believe we all agree on that, and it's the standard that has
> a wrong approach here.
> 

I think that the standard has the aliasing rules, not
because the comittee wanted to deny float->integer-bit-pattern
conversions but because the comittee wanted the compiler
produce better code in some other common situations.

For example for some floating point vector library it is
useful for the compiler to be sure that none of the
limit/index integer values change, when the floating
point results are written out. I think the aliasing rules
make it easier to compete with fortran compilers here.

The problem with int x=*(int *)&f; is sort of side effect here.
I don't really know for sure why there must be a problem,
because the aliasing of the values is sort of obvious, and could
be deduced separately.  Maybe the comittee just wanted to
keep the definitions simple?


		Eero





-------------------------------------------------------
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.