NormanDunbar wrote:Evening All,
I'm writing a utility - it's a long term project of mine - in C68. For testing I'm using both xtcc on Linux, and compiling the code with gcc as well. I'm needing some code to convert a QL 6 byte floating point to a "normal" floating point both in C68 (native to the QL) and also for a float variable under gcc - purely for testing.
I'm assuming that floats under C68 are normal QL floats and will not need converting - I seem to remember this, but I might be wrong, but the "standard" float on Linux under gcc is way different. Can anyone point me at/supply a chunk of code to do the conversion please?
Much obliged. And, one day, If I ever finish this, you'll all be the first to know!
Cheers,
Norm.
Norman,
Nope. C68 uses its own (or, rather IEEE) floating point format, different from and more precise than the QL's native format (it uses 8 bytes instead of six). C68 still can handle 6-byte QL floats, these are of type "QLFLOAT_t". That is, a Linux gcc "double" has the very same format as a C68 one.
Conversion between both formats is simple on C68:
Code: Select all
QLFLOAT_t * d_to_qlfp( QLFLOAT_t * qlf, double val)
takes a double and converts it to a QLFLOAT_t and
Code: Select all
double qlfp_to_d (QLFLOAT_t * qlfp)
goes the other way round.
For gcc, it's probably a bit more complicated - I'd look into the C68 library sources and port the above two routines.
Tobias