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

Comparing libecb/ecb.h (file contents):
Revision 1.147 by root, Fri Oct 17 12:25:01 2014 UTC vs.
Revision 1.148 by root, Fri Oct 24 04:50:13 2014 UTC

670 #define ECB_NAN NAN 670 #define ECB_NAN NAN
671 #else 671 #else
672 #define ECB_NAN ECB_INFINITY 672 #define ECB_NAN ECB_INFINITY
673 #endif 673 #endif
674 674
675 #if ECB_C99 || _XOPEN_VERSION >= 600 || _POSIX_VERSION >= 200112L
676 #define ecb_ldexpf(x,e) ldexpf ((x), (e))
677 #else
678 #define ecb_ldexpf(x,e) (float) ldexp ((double)(x), (e))
679 #endif
680
675 /* converts an ieee half/binary16 to a float */ 681 /* converts an ieee half/binary16 to a float */
676 ecb_function_ float ecb_binary16_to_float (uint16_t x) ecb_const; 682 ecb_function_ float ecb_binary16_to_float (uint16_t x) ecb_const;
677 ecb_function_ float 683 ecb_function_ float
678 ecb_binary16_to_float (uint16_t x) 684 ecb_binary16_to_float (uint16_t x)
679 { 685 {
680 int e = (x >> 10) & 0x1f; 686 int e = (x >> 10) & 0x1f;
681 int m = x & 0x3ff; 687 int m = x & 0x3ff;
682 float r; 688 float r;
683 689
684 if (!e ) r = ldexpf (m , -24); 690 if (!e ) r = ecb_ldexpf (m , -24);
685 else if (e != 31) r = ldexpf (m + 0x400, e - 25); 691 else if (e != 31) r = ecb_ldexpf (m + 0x400, e - 25);
686 else if (m ) r = ECB_NAN; 692 else if (m ) r = ECB_NAN;
687 else r = ECB_INFINITY; 693 else r = ECB_INFINITY;
688 694
689 return x & 0x8000 ? -r : r; 695 return x & 0x8000 ? -r : r;
690 } 696 }
749 x |= 0x800000U; 755 x |= 0x800000U;
750 else 756 else
751 e = 1; 757 e = 1;
752 758
753 /* we distrust ldexpf a bit and do the 2**-24 scaling by an extra multiply */ 759 /* we distrust ldexpf a bit and do the 2**-24 scaling by an extra multiply */
754 r = ldexpf (x * (0.5f / 0x800000U), e - 126); 760 r = ecb_ldexpf (x * (0.5f / 0x800000U), e - 126);
755 761
756 r = neg ? -r : r; 762 r = neg ? -r : r;
757 #endif 763 #endif
758 764
759 return r; 765 return r;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines