msg01004.html
1998Q3/msg01004.html · 8.4 KB
From the archive 1998Q3.zip
Download the archive « Back to the archive contents
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes? -->
<!--X-From-R13: "Ayn Tbfurvz Ueøfgnq" <byntNvsv.hvb.ab> -->
<!--X-Date: Thu, 10 Sep 1998 01:07:56 -0700 -->
<!--X-Message-Id: 35F78741.B4C6D57C#ifi,uio.no -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: Pine.BSF.4.02A.9809091438220.29160-100000#schultz,io.com -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:olag#ifi,uio.no">
</head>
<body background="/backgrounds/paperback.gif" bgcolor="#ffffff"
text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000">
<font size="+4" color="#804040">
<strong><em>MUD-Dev<br>mailing list archive</em></strong>
</font>
<br>
[ <a href="../">Other Periods</a>
| <a href="../../">Other mailing lists</a>
| <a href="/search.php3">Search</a>
]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->
Date:
[ <a href="msg01003.html">Previous</a>
| <a href="msg01005.html">Next</a>
]
Thread:
[ <a href="msg00996.html">Previous</a>
| <a href="msg00982.html">Next</a>
]
Index:
[ <A HREF="author.html#01004">Author</A>
| <A HREF="#01004">Date</A>
| <A HREF="thread.html#01004">Thread</A>
]
<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Subject</em>: [MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</LI>
<LI><em>From</em>: "Ola Fosheim Grøstad" <<A HREF="mailto:olag#ifi,uio.no">olag#ifi,uio.no</A>></LI>
<LI><em>Date</em>: Thu, 10 Sep 1998 10:01:05 +0200</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
Travis S. Casey wrote:
> On Wed, 9 Sep 1998, Ola Fosheim Grøstad wrote:
> > Depending on the compiler the following should fix errors introduced by
> > optimization?
> >
> > volatile float f = 42.5f;
>
> If I understand the "volatile" keyword correctly, it tells the compiler
> that other programs may be able to change the data object in question, and
> therefore, the program should not try to optimize out references to the
> variable.
[...]
> However, it *doesn't* tell the compiler not to optimize uses of the
> variable in other ways... hence, a "fast math" library might still
> introduce rounding errors or other errors... it just would actually access
> the variable every time its value was requested.
>
> Again, this is if my understanding of "volatile" is correct.
Hmm... I guess you are right, but volatile doesn't strictly *tell* the
compiler anything, it is a hint suggesting that optimization may not be such
a great idea. (so I should have written "could" and not "should").
Quoting K&R "The C programming language" (2nd ed) p 211:
"There are no implementation-independent semantics for volatile objects."
"The purpose of volatile is to force an implementation to suppress
optimization that could otherwise occur. For example, for a machine
with memory-mapped input/output [...] a compiler may ignore these
qualifiers"
"C++ ARM" (1992) is specific about aggressive optimization and concurrent
changes though, but it is still a hint. Dunno about the ANSI spec. Given
that compilers can be somewhat sloppy about standards you basically have to
know your compiler anyway :-(( An obvious alternative would be to throw
the conversion code in a separate object file (Depending on whether the
fast-math option requires a global recompilation, which would make the
option less useful.)
And I don't think the implied trouble was rounding errors, but whether &f
points to a valid IEEE float or not? "Buggy" optimization is generally a
compiler issue and not a language issue, but volatile or separate
nonoptimized compilation could be worth testing out if one runs into this
kind of trouble (my experience). When it comes to optimization we
unfortunatly place our sanity in the hands of the allmighty Compiler Imps
and their knowledge of the art of program verification (or lack thereof).
(Did anyone mention g++?).
--
Ola Fosheim Groestad,Norway
</PRE>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00996" HREF="msg00996.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></STRONG>
<UL><LI><EM>From:</EM> "Travis S. Casey" <efindel#io,com></LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg01003.html">[MUD-Dev] Re: Implementing god.</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg01005.html">[MUD-Dev] Re: Implementing god.</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00996.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00982.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#01004"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#01004"><STRONG>Thread</STRONG></A></LI>
</UL>
</LI>
</UL>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
<ul><li>Thread context:
<BLOCKQUOTE><UL>
<LI><STRONG>[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<LI><strong><A NAME="00987" HREF="msg00987.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></strong>,
T. Alexander Popiel <a href="mailto:popiel#snugharbor,com">popiel#snugharbor,com</a>, Mon 07 Sep 1998, 22:44 GMT
</LI>
</ul>
</ul>
<LI><strong><A NAME="00991" HREF="msg00991.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></strong>,
Adam Wiggins <a href="mailto:adam#angel,com">adam#angel,com</a>, Tue 08 Sep 1998, 19:26 GMT
<UL>
<LI><strong><A NAME="00995" HREF="msg00995.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></strong>,
Ola Fosheim Grøstad <a href="mailto:olag#ifi,uio.no">olag#ifi,uio.no</a>, Wed 09 Sep 1998, 19:14 GMT
<UL>
<LI><strong><A NAME="00996" HREF="msg00996.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></strong>,
Travis S. Casey <a href="mailto:efindel#io,com">efindel#io,com</a>, Wed 09 Sep 1998, 19:43 GMT
<UL>
<LI><strong><A NAME="01004" HREF="msg01004.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></strong>,
Ola Fosheim Grøstad <a href="mailto:olag#ifi,uio.no">olag#ifi,uio.no</a>, Thu 10 Sep 1998, 08:07 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</ul>
</ul>
<LI><strong><A NAME="00982" HREF="msg00982.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></strong>,
Ben Greear <a href="mailto:greear#cyberhighway,net">greear#cyberhighway,net</a>, Mon 07 Sep 1998, 17:47 GMT
<UL>
<LI><strong><A NAME="00983" HREF="msg00983.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></strong>,
Richard Woolcock <a href="mailto:KaVir#dial,pipex.com">KaVir#dial,pipex.com</a>, Mon 07 Sep 1998, 18:05 GMT
</LI>
</UL>
</LI>
</ul>
<LI><strong><A NAME="00994" HREF="msg00994.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></strong>,
J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Wed 09 Sep 1998, 17:33 GMT
<UL>
<LI><strong><A NAME="00997" HREF="msg00997.html">[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?</A></strong>,
Adam J. Thornton <a href="mailto:adam#phoenix,Princeton.EDU">adam#phoenix,Princeton.EDU</a>, Wed 09 Sep 1998, 22:30 GMT
</LI>
</UL>
</LI>
</ul>
</LI>
</UL></BLOCKQUOTE>
</ul>
<hr>
<center>
[ <a href="../">Other Periods</a>
| <a href="../../">Other mailing lists</a>
| <a href="/search.php3">Search</a>
]
</center>
<hr>
</body>
</html>