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?
In message: <Pine.LNX.3.96.980906215952.30075A-100000#shamen,cyberhighway.net>
Ben Greear <greear#cyberhighway,net> writes:
>
>What is the standard way (if there is one) to encode floating
>point numbers (double too I guess) into bytes for transport accross
>the network.
>
>I'm using c++, on both ends (encode/decode).
>
>It would seem like there would be a method to do this somewhere!
Standard is to send raw IEEE format across the wire; just about
everyone uses IEEE internally these days, and those who don't
know how to convert, so they can talk with those that do.
IEEE 32-bit format is bigendian: 1 sign bit, 8 bits exponent in
offset 127 notation, implied 1 (not stored), 23 bits mantissa.
Special codes are used in the exponent to denote NaN, +/-Inf,
and reduced-precision numbers between 2^-128 and 2^-152.
IEEE 64-bit is similar, with 16 bits exponent and 47 bits
mantissa.
If you do the conversion manually, actually check the standard;
I prolly have an off-by-one error in the above (which was taken
from memory).
- Alex
- Thread context:
- [MUD-Dev] PERL based MUDs,
J C Lawrence claw#under,engr.sgi.com, Wed 09 Sep 1998, 23:52 GMT
- [MUD-Dev] A Java front end to ECGS (finally),
J C Lawrence claw#under,engr.sgi.com, Wed 09 Sep 1998, 23:50 GMT
- [MUD-Dev] Adventure on the web,
J C Lawrence claw#under,engr.sgi.com, Tue 08 Sep 1998, 21:01 GMT
- [MUD-Dev] [CODE QUESTION] How to encode floats into bytes?,
Ben Greear greear#cyberhighway,net, Mon 07 Sep 1998, 05:09 GMT
[ Other Periods
| Other mailing lists
| Search
]