diff --git a/modules/src/flt_arith/flt_ar2flt.c b/modules/src/flt_arith/flt_ar2flt.c index c1cb7b2a4..4fe418674 100644 --- a/modules/src/flt_arith/flt_ar2flt.c +++ b/modules/src/flt_arith/flt_ar2flt.c @@ -21,10 +21,22 @@ flt_arith2flt(n, e, uns) } else e->flt_sign = 0; if (sizeof(arith) == 4) { - e->m1 = n; e->m2 = 0; - } else { - e->m1 = (n >> (sizeof(arith)*8 - 32)) & 0xFFFFFFFF; - e->m2 = n << 32; + if (n < 0) { + e->m1 = 1; e->m2 = 0; + } + else { + e->m1 = 0; e->m2 = n; + } + } + else { + if (n < 0) { + e->m2 = 0; + e->m1 = (1 << (sizeof(arith)*8-32)); + } + else { + e->m2 = n & 0xffffffffL; + e->m1 = (n >> 32); + } } if (n == 0) { e->flt_exp = 0;