hi, for this testcase,remaider() will enter an endless loop: rounding is TONEAREST x=(7fefffff,ffffffff),y=(00000000,00000001) attached is a little program to test it(gcc t-remainder.c -lm) most important part is listed here: while (l>0) { ... printf("u=(%08lx,%08lx),d=(%08lx,%08lx),w=(%08lx,%08lx)\n",u.i[1],u.i[0],tmp2.i[1],tmp2.i[0],w.i[1],w.i[0]); tmp1.x = d*w.x; tmp2.x = u.x - tmp1.x; u.x=(u.x-d*w.x)/*-d*ww.x*/; printf("d*w=(%08lx,%08lx),u.x-d*w=(%08lx,%08lx),u=(%08lx,%08lx)\n",tmp1.i[1],tmp1.i[0],tmp2.i[1],tmp2.i[0],u.i[1],u.i[0]); l=(u.i[HIGH_HALF]&0x7ff00000)-nn; } It is weird enough for me that u doesn't equal to tmp2,that is where x86 and mips differ. the output from my P4: rounding is TONEAREST x=(7fefffff,ffffffff),y=(00000000,00000001) x=(7fefffff,ffffffff),y=(04d00000,00000000) 1/y=7b100000,00000000 n=04d00000,nn=06100000,ww=(00000000,00000000),w=(04d00000,00000000),l=79d00000 u=(7fefffff,ffffffff),d=(41400000,00000000),w=(7ea00000,00000000) d*w=(7ff00000,00000000),u.x-d*w=(fff00000,00000000),u=(fca00000,00000000) <--notice this u=(fca00000,00000000),d=(c1300000,00000000),w=(7b600000,00000000) d*w=(fca00000,00000000),u.x-d*w=(00000000,00000000),u=(00000000,00000000) x=(00000000,00000000),y=(04d00000,00000000) output from mipsel: rounding is TONEAREST x=(7fefffff,ffffffff),y=(00000000,00000001) x=(7fefffff,ffffffff),y=(04d00000,00000000) 1/y=7b100000,00000000 n=04d00000,nn=06100000,ww=(00000000,00000000),w=(04d00000,00000000),l=79d00000 u=(7fefffff,ffffffff),d=(41400000,00000000),w=(7ea00000,00000000) d*w=(7ff00000,00000000),u.x-d*w=(fff00000,00000000),u=(fff00000,00000000) <--notice this u=(fff00000,00000000),d=(fff00000,00000000),w=(7eb00000,00000000) d*w=(fff00000,00000000),u.x-d*w=(7ff7ffff,ffffffff),u=(7ff7ffff,ffffffff) u=(7ff7ffff,ffffffff),d=(7ff7ffff,ffffffff),w=(7eb00000,00000000) d*w=(7ff7ffff,ffffffff),u.x-d*w=(7ff7ffff,ffffffff),u=(7ff7ffff,ffffffff) u=(7ff7ffff,ffffffff),d=(7ff7ffff,ffffffff),w=(7eb00000,00000000) d*w=(7ff7ffff,ffffffff),u.x-d*w=(7ff7ffff,ffffffff),u=(7ff7ffff,ffffffff) u=(7ff7ffff,ffffffff),d=(7ff7ffff,ffffffff),w=(7eb00000,00000000) d*w=(7ff7ffff,ffffffff),u.x-d*w=(7ff7ffff,ffffffff),u=(7ff7ffff,ffffffff) ... Thank you. Regards Zhang Fuxin fxzhang@ict.ac.cn
Attachment:
t-remainder.c
Description: Binary data