MUD-Dev
mailing list archive
[ Other Periods
| Other mailing lists
| Search
]
Date:
[ Previous
| Next
]
Thread:
[ Previous
| Next
]
Index:
[ Author
| Date
| Thread
]
[MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?
On Mon, 7 Sep 1998, Ben Greear wrote:
> I'm perfectly happy sending bits across in IEEE 754 format. However,
> I don't know how to get the bits. Can you bit-mask floats? Basically,
> I need a way to grab the mantissa and the exponent as either raw bits
> or integers. Then I can pack it according to the IEEE standard.
>
> Maybe I'm being too complicated. Maybe something like this would encode:
>
> file_descriptor f; //assume it's connected appropriately.
> float f = 42.5;
> char* bytes = (char*)(&f);
> write(f, bytes, 0, 4); //think those args are right..
>
> This ignores network order, but I can deal with that.
Not only that, but if you decide to compile with -ffast-math one day, you
may get some funny results.
- Thread context:
- [MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?, (continued)
- [MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?,
Richard Woolcock KaVir#dial,pipex.com, Mon 07 Sep 1998, 18:07 GMT
- [MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?,
Ola Fosheim Grøstad olag#ifi,uio.no, Mon 07 Sep 1998, 20:44 GMT
- [MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?,
Adam Wiggins adam#angel,com, Tue 08 Sep 1998, 19:26 GMT
- [MUD-Dev] Re: [CODE QUESTION] How to encode floats into bytes?,
Ben Greear greear#cyberhighway,net, Mon 07 Sep 1998, 17:47 GMT
[ Other Periods
| Other mailing lists
| Search
]