Page 1 of 1

Displaying a packed floating point number in C#

Posted: Fri Oct 15, 2010 11:26 pm
by Yicker
Hi,

I need to convert a packed floating point number as stored by the Oric to it's original value.

For example

Code: Select all

118 would be stored as #87 #66 #00 #00 #00
Can anyone tell me how I can convert it back to it's original value of decimal 118 using C#


Cheers
Scott

Posted: Sat Oct 16, 2010 6:46 am
by JamesD

Posted: Sat Oct 16, 2010 7:23 am
by JamesD
BTW, you can find a similar topic on the worldofspectrum.org started recently.
http://www.worldofspectrum.org/forums/s ... hp?t=31499

Posted: Sat Oct 16, 2010 7:30 am
by JamesD

Posted: Sat Oct 16, 2010 7:34 am
by JamesD
Look for other 8 bit computer 5 byte format floating point numbers.
It will be 4 bytes representing the number, 1 bit the sign, and 7 bits the exponent. At least if it is consistent with other machines.

Posted: Sat Oct 16, 2010 1:32 pm
by Dbug
Look at the C compiler source code:
http://miniserve.getmyip.com/svn/public ... rces/gen.c

The void printfloat(double val) routine is charged to convert a double accuracy floating point value to a 5 byte format.

Doing the opposite is not much complex I guess :)