+
+/****************************************************************/
+
+
+WXDLLEXPORT void wxConvertToIeeeExtended(wxFloat64 num, wxInt8 *bytes)
+{
+ wxInt32 sign;
+ wxInt32 expon;
+ wxFloat64 fMant, fsMant;
+ wxUint32 hiMant, loMant;
+
+ if (num < 0) {
+ sign = 0x8000;
+ num *= -1;
+ } else {
+ sign = 0;
+ }
+
+ if (num == 0) {
+ expon = 0; hiMant = 0; loMant = 0;
+ }
+ else {
+ fMant = frexp(num, &expon);
+ if ((expon > 16384) || !(fMant < 1)) { /* Infinity or NaN */
+ expon = sign|0x7FFF; hiMant = 0; loMant = 0; /* infinity */
+ }
+ else { /* Finite */
+ expon += 16382;
+ if (expon < 0) { /* denormalized */
+ fMant = ldexp(fMant, expon);
+ expon = 0;
+ }
+ expon |= sign;
+ fMant = ldexp(fMant, 32); fsMant = floor(fMant); hiMant = FloatToUnsigned(fsMant);
+ fMant = ldexp(fMant - fsMant, 32); fsMant = floor(fMant); loMant = FloatToUnsigned(fsMant);
+ }
+ }
+
+ bytes[0] = expon >> 8;
+ bytes[1] = expon;
+ bytes[2] = hiMant >> 24;
+ bytes[3] = hiMant >> 16;
+ bytes[4] = hiMant >> 8;
+ bytes[5] = hiMant;
+ bytes[6] = loMant >> 24;
+ bytes[7] = loMant >> 16;
+ bytes[8] = loMant >> 8;
+ bytes[9] = loMant;
+}
+
+#if WXWIN_COMPATIBILITY_2_8
+WXDLLEXPORT wxFloat64 ConvertFromIeeeExtended(const wxInt8 *bytes)
+{
+ return wxConvertFromIeeeExtended(bytes);
+}
+
+WXDLLEXPORT void ConvertToIeeeExtended(wxFloat64 num, wxInt8 *bytes)
+{
+ wxConvertToIeeeExtended(num, bytes);
+}
+#endif // WXWIN_COMPATIBILITY_2_8
+