[Home] [Groups] - Message: [Prev in Group] [Next in Group]

nu.kanga.list.mud-dev

7183: [MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?

[Full Header] [Plain Text]
From: "Ola Fosheim Grøstad" <olag@ifi.uio.no>
Newsgroups: nu.kanga.list.mud-dev
Date: Wed, 09 Sep 1998 18:47:47 +0200
References: [1]
Organization: Kanga.Nu
Adam Wiggins wrote:
> On Mon, 7 Sep 1998, Ben Greear wrote:

> > float f = 42.5;
> > char* bytes = (char*)(&f);

> Not only that, but if you decide to compile with -ffast-math one day, you
> may get some funny results.

Depending on the compiler the following should fix errors introduced by
optimization?

  volatile float f = 42.5f;

--
Ola Fosheim Groestad,Norway