ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libecb/ecb.h
(Generate patch)

Comparing libecb/ecb.h (file contents):
Revision 1.107 by root, Fri Jun 29 00:56:30 2012 UTC vs.
Revision 1.108 by root, Fri Jun 29 01:39:51 2012 UTC

573 /* slow emulation, works for anything but -0 */ 573 /* slow emulation, works for anything but -0 */
574 ECB_EXTERN_C float frexpf (float v, int *e); 574 ECB_EXTERN_C float frexpf (float v, int *e);
575 uint32_t m; 575 uint32_t m;
576 int e; 576 int e;
577 577
578 if (x == 0e0f ) return 0; 578 if (x == 0e0f ) return 0x00000000U;
579 if (x > +3.40282346638528860e+38f) return 0x7f800000U; 579 if (x > +3.40282346638528860e+38f) return 0x7f800000U;
580 if (x < -3.40282346638528860e+38f) return 0xff800000U; 580 if (x < -3.40282346638528860e+38f) return 0xff800000U;
581 if (x != x ) return 0x7fbfffffU; 581 if (x != x ) return 0x7fbfffffU;
582 582
583 m = frexpf (x, &e) * 0x1000000U; 583 m = frexpf (x, &e) * 0x1000000U;
585 r = m & 0x80000000U; 585 r = m & 0x80000000U;
586 586
587 if (r) 587 if (r)
588 m = -m; 588 m = -m;
589 589
590 if (e < -125) 590 if (e <= -126)
591 { 591 {
592 m &= 0xffffffU; 592 m &= 0xffffffU;
593 m >>= (-125 - e); 593 m >>= (-125 - e);
594 e = -126; 594 e = -126;
595 } 595 }
623 x |= 0x800000U; 623 x |= 0x800000U;
624 else 624 else
625 e = 1; 625 e = 1;
626 626
627 /* we distrust ldexpf a bit and do the 2**-24 scaling by an extra multiply */ 627 /* we distrust ldexpf a bit and do the 2**-24 scaling by an extra multiply */
628 r = ldexpf (x * (1.f / 0x1000000U), e - 126); 628 r = ldexpf (x * (0.5f / 0x800000U), e - 126);
629 629
630 r = neg ? -r : r; 630 r = neg ? -r : r;
631 #endif 631 #endif
632 632
633 return r; 633 return r;
646 /* slow emulation, works for anything but -0 */ 646 /* slow emulation, works for anything but -0 */
647 ECB_EXTERN_C double frexp (double v, int *e); 647 ECB_EXTERN_C double frexp (double v, int *e);
648 uint64_t m; 648 uint64_t m;
649 int e; 649 int e;
650 650
651 if (x == 0e0 ) return 0; 651 if (x == 0e0 ) return 0x0000000000000000U;
652 if (x > +1.79769313486231470e+308) return 0x7ff0000000000000U; 652 if (x > +1.79769313486231470e+308) return 0x7ff0000000000000U;
653 if (x < -1.79769313486231470e+308) return 0xfff0000000000000U; 653 if (x < -1.79769313486231470e+308) return 0xfff0000000000000U;
654 if (x != x ) return 0X7ff7ffffffffffffU; 654 if (x != x ) return 0X7ff7ffffffffffffU;
655 655
656 m = frexp (x, &e) * 0x20000000000000U; 656 m = frexp (x, &e) * 0x20000000000000U;
658 r = m & 0x8000000000000000;; 658 r = m & 0x8000000000000000;;
659 659
660 if (r) 660 if (r)
661 m = -m; 661 m = -m;
662 662
663 if (e < -1021) 663 if (e <= -1022)
664 { 664 {
665 m &= 0x1fffffffffffffU; 665 m &= 0x1fffffffffffffU;
666 m >>= (-1021 - e); 666 m >>= (-1021 - e);
667 e = -1022; 667 e = -1022;
668 } 668 }
696 x |= 0x10000000000000U; 696 x |= 0x10000000000000U;
697 else 697 else
698 e = 1; 698 e = 1;
699 699
700 /* we distrust ldexp a bit and do the 2**-53 scaling by an extra multiply */ 700 /* we distrust ldexp a bit and do the 2**-53 scaling by an extra multiply */
701 r = ldexp (x * (1. / 0x20000000000000U), e - 1022); 701 r = ldexp (x * (0.5 / 0x10000000000000U), e - 1022);
702 702
703 r = neg ? -r : r; 703 r = neg ? -r : r;
704 #endif 704 #endif
705 705
706 return r; 706 return r;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines