Changeset 2f08a55d in mainline for arch/amd64/src/fmath.c


Ignore:
Timestamp:
2005-09-03T14:16:25Z (19 years ago)
Author:
Josef Cejka <malyzelenyhnus@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f6297e0
Parents:
544b4bf
Message:

Support for NaN and infinity in printf.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/src/fmath.c

    r544b4bf r2f08a55d  
    3232        //TODO:
    3333#define FMATH_MANTISA_MASK ( 0x000fffffffffffffLL )
    34 
    35 int fmath_is_negative(double num)
    36 {       //TODO:
    37 /*      fmath_ld_union_t fmath_ld_union;
    38         fmath_ld_union.bf = num;
    39         return ((fmath_ld_union.ldd[7])&0x80)==0x80; //first bit is sign, IA32 is little endian -> 8th byte
    40 */
    41         return 0;
    42 }
    4334
    4435signed short fmath_get_binary_exponent(double num)
     
    117108};
    118109       
    119 double fmath_set_sign(double num,__u8 sign)
    120 {       //TODO:
    121 /*      fmath_ld_union_t fmath_ld_union;
    122         fmath_ld_union.bf = num;
    123         fmath_ld_union.ldd[7]=((fmath_ld_union.ldd[7])&0x7f)|(sign<<7); // change 64th bit (IA32 is a little endian)
    124         return fmath_ld_union.bf;
    125 */      return 1.0;
    126 }
    127 
    128 double fmath_abs(double num)
    129 {       //TODO:
    130 /*
    131         return fmath_set_sign(num,0);
    132 */
    133         return 1.0;
    134 }
    135110
    136111double fmath_dpow(double base, double exponent)
     
    158133}
    159134
     135
     136int fmath_is_nan(double num)
     137{
     138/*      __u16 exp;
     139        fmath_ld_union_t fmath_ld_union;
     140        fmath_ld_union.bf = num;
     141        exp=(((fmath_ld_union.ldd[7])&0x7f)<<4) + (((fmath_ld_union.ldd[6])&0xf0)>>4); // exponent is 11 bits lenght, so sevent bits is in 8th byte and 4 bits in 7th
     142
     143        if (exp!=0x07ff) return 0;
     144        if (fmath_get_binary_mantisa(num)>=FMATH_NAN) return 1;
     145       
     146*/             
     147        return 0;
     148}
     149
     150int fmath_is_infinity(double num)
     151{
     152/*      __u16 exp;
     153        fmath_ld_union_t fmath_ld_union;
     154        fmath_ld_union.bf = num;
     155        exp=(((fmath_ld_union.ldd[7])&0x7f)<<4) + (((fmath_ld_union.ldd[6])&0xf0)>>4); // exponent is 11 bits lenght, so sevent bits is in 8th byte and 4 bits in 7th
     156
     157        if (exp!=0x07ff) return 0;
     158        if (fmath_get_binary_mantisa(num)==0x0) return 1;
     159*/      return 0;
     160}
     161
Note: See TracChangeset for help on using the changeset viewer.