Changeset 2f08a55d in mainline
- Timestamp:
- 2005-09-03T14:16:25Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f6297e0
- Parents:
- 544b4bf
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/include/fmath.h
r544b4bf r2f08a55d 35 35 typedef union { double bf; unsigned char ldd[8]; } fmath_ld_union_t; 36 36 37 int fmath_is_negative(double num);38 //int fmath_is_exponent_negative(double num);39 40 37 /**returns exponent in binary encoding*/ 41 38 signed short fmath_get_binary_exponent(double num); … … 54 51 double fmath_fint(double num, double *intp); 55 52 56 /** Return absolute value from num */57 double fmath_abs(double num);58 59 double fmath_set_sign(double num,__u8 sign);60 61 53 /** count base^exponent from positive exponent 62 54 * @param base … … 66 58 double fmath_dpow(double base, double exponent) ; 67 59 60 /** return 1, if num is NaN */ 61 int fmath_is_nan(double num); 62 63 /** return 1, if fmath is a infinity */ 64 int fmath_is_infinity(double num); -
arch/amd64/src/fmath.c
r544b4bf r2f08a55d 32 32 //TODO: 33 33 #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 byte40 */41 return 0;42 }43 34 44 35 signed short fmath_get_binary_exponent(double num) … … 117 108 }; 118 109 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 }135 110 136 111 double fmath_dpow(double base, double exponent) … … 158 133 } 159 134 135 136 int 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 150 int 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 -
arch/ia32/include/fmath.h
r544b4bf r2f08a55d 35 35 typedef union { double bf; unsigned char ldd[8]; } fmath_ld_union_t; 36 36 37 int fmath_is_negative(double num);38 //int fmath_is_exponent_negative(double num);39 40 37 /**returns exponent in binary encoding*/ 41 38 signed short fmath_get_binary_exponent(double num); … … 54 51 double fmath_fint(double num, double *intp); 55 52 56 /** Return absolute value from num */57 double fmath_abs(double num);58 59 double fmath_set_sign(double num,__u8 sign);60 61 53 /** count base^exponent from positive exponent 62 54 * @param base … … 66 58 double fmath_dpow(double base, double exponent) ; 67 59 60 /** return 1, if num is NaN */ 61 int fmath_is_nan(double num); 62 63 /** return 1, if fmath is a infinity */ 64 int fmath_is_infinity(double num); -
arch/ia32/src/fmath.c
r544b4bf r2f08a55d 31 31 32 32 #define FMATH_MANTISA_MASK ( 0x000fffffffffffffLL ) 33 34 int fmath_is_negative(double num) 35 { 36 fmath_ld_union_t fmath_ld_union; 37 fmath_ld_union.bf = num; 38 return ((fmath_ld_union.ldd[7])&0x80)==0x80; /*first bit is sign, IA32 is little endian -> 8th byte*/ 39 40 } 41 33 #define FMATH_NAN ( 0x0001000000000001LL ) 42 34 signed short fmath_get_binary_exponent(double num) 43 35 { … … 78 70 if (exp<0) { 79 71 *intp = 0.0; 80 *intp = fmath_set_sign(0.0L,fmath_is_negative(num));81 72 return num; 82 73 } … … 86 77 *intp=num; 87 78 num=0.0; 88 num= fmath_set_sign(0.0L,fmath_is_negative(*intp));89 79 return num; 90 80 } … … 107 97 }; 108 98 109 double fmath_set_sign(double num,__u8 sign)110 {111 fmath_ld_union_t fmath_ld_union;112 fmath_ld_union.bf = num;113 fmath_ld_union.ldd[7]=((fmath_ld_union.ldd[7])&0x7f)|(sign<<7); /* change 64th bit (IA32 is a little endian)*/114 return fmath_ld_union.bf;115 }116 117 double fmath_abs(double num)118 {119 return fmath_set_sign(num,0);120 }121 99 122 100 double fmath_dpow(double base, double exponent) … … 142 120 } 143 121 122 int fmath_is_nan(double num) 123 { 124 __u16 exp; 125 fmath_ld_union_t fmath_ld_union; 126 fmath_ld_union.bf = num; 127 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 */ 128 129 if (exp!=0x07ff) return 0; 130 if (fmath_get_binary_mantisa(num)>=FMATH_NAN) return 1; 131 132 133 return 0; 134 } 135 136 int fmath_is_infinity(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)==0x0) return 1; 145 return 0; 146 } -
arch/ia64/include/fmath.h
r544b4bf r2f08a55d 35 35 typedef union { double bf; unsigned char ldd[8]; } fmath_ld_union_t; 36 36 37 int fmath_is_negative(double num);38 //int fmath_is_exponent_negative(double num);39 40 37 /**returns exponent in binary encoding*/ 41 38 signed short fmath_get_binary_exponent(double num); … … 54 51 double fmath_fint(double num, double *intp); 55 52 56 /** Return absolute value from num */57 double fmath_abs(double num);58 59 double fmath_set_sign(double num,__u8 sign);60 61 53 /** count base^exponent from positive exponent 62 54 * @param base … … 66 58 double fmath_dpow(double base, double exponent) ; 67 59 60 /** return 1, if num is NaN */ 61 int fmath_is_nan(double num); 62 63 /** return 1, if fmath is a infinity */ 64 int fmath_is_infinity(double num); -
arch/ia64/src/fmath.c
r544b4bf r2f08a55d 32 32 //TODO: 33 33 #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 byte40 */41 return 0;42 }43 34 44 35 signed short fmath_get_binary_exponent(double num) … … 117 108 }; 118 109 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 }135 110 136 111 double fmath_dpow(double base, double exponent) … … 158 133 } 159 134 135 136 int 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 150 int 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 -
arch/mips/include/fmath.h
r544b4bf r2f08a55d 35 35 typedef union { double bf; unsigned char ldd[8]; } fmath_ld_union_t; 36 36 37 int fmath_is_negative(double num);38 //int fmath_is_exponent_negative(double num);39 40 37 /**returns exponent in binary encoding*/ 41 38 signed short fmath_get_binary_exponent(double num); … … 54 51 double fmath_fint(double num, double *intp); 55 52 56 /** Return absolute value from num */57 double fmath_abs(double num);58 59 double fmath_set_sign(double num,__u8 sign);60 61 53 /** count base^exponent from positive exponent 62 54 * @param base … … 66 58 double fmath_dpow(double base, double exponent) ; 67 59 60 /** return 1, if num is NaN */ 61 int fmath_is_nan(double num); 62 63 /** return 1, if fmath is a infinity */ 64 int fmath_is_infinity(double num); -
arch/mips/src/fmath.c
r544b4bf r2f08a55d 32 32 //TODO: 33 33 #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 byte40 */41 return 0;42 }43 34 44 35 signed short fmath_get_binary_exponent(double num) … … 117 108 }; 118 109 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 }135 110 136 111 double fmath_dpow(double base, double exponent) … … 158 133 } 159 134 135 136 int 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 150 int 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 -
arch/ppc/include/fmath.h
r544b4bf r2f08a55d 35 35 typedef union { double bf; unsigned char ldd[8]; } fmath_ld_union_t; 36 36 37 int fmath_is_negative(double num);38 //int fmath_is_exponent_negative(double num);39 40 37 /**returns exponent in binary encoding*/ 41 38 signed short fmath_get_binary_exponent(double num); … … 54 51 double fmath_fint(double num, double *intp); 55 52 56 /** Return absolute value from num */57 double fmath_abs(double num);58 59 double fmath_set_sign(double num,__u8 sign);60 61 53 /** count base^exponent from positive exponent 62 54 * @param base … … 66 58 double fmath_dpow(double base, double exponent) ; 67 59 60 /** return 1, if num is NaN */ 61 int fmath_is_nan(double num); 62 63 /** return 1, if fmath is a infinity */ 64 int fmath_is_infinity(double num); -
arch/ppc/src/fmath.c
r544b4bf r2f08a55d 32 32 //TODO: 33 33 #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 byte40 */41 return 0;42 }43 34 44 35 signed short fmath_get_binary_exponent(double num) … … 117 108 }; 118 109 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 }135 110 136 111 double fmath_dpow(double base, double exponent) … … 158 133 } 159 134 135 136 int 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 150 int 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 -
src/debug/print.c
r544b4bf r2f08a55d 50 50 unsigned long in1,in2; 51 51 52 /* 52 53 53 if (fmath_is_nan(num)) { 54 54 print_str("NaN"); 55 55 return; 56 56 } 57 */ 58 59 if (fmath_is_negative(num)) { 57 58 if (num<0.0) { 60 59 putchar('-'); 61 } 62 63 num=fmath_abs(num); 60 num=num*-1.0; 61 } 62 63 64 if (fmath_is_infinity(num)) { 65 print_str("Inf"); 66 return; 67 } 64 68 65 69 if ((modifier=='E')||(modifier=='e')) { … … 79 83 } 80 84 81 82 /*83 if (fmath_is_infinity(num)) {84 print_str("Inf");85 }86 */87 85 //TODO: rounding constant - when we got fraction >= 0.5, we must increment last printed number 88 86 -
test/print/print1/test.c
r544b4bf r2f08a55d 32 32 { 33 33 __u64 u64const = 0x0123456789ABCDEFLL; 34 double d; 34 35 printf(" Printf test \n"); 35 36 printf(" Q %Q %q \n",u64const, u64const); … … 48 49 printf(" E %.10E %.8e (123456789.987654321e12 for precision 10 & 8)\n",123456789.987654321e12,123456789.987654321e12); 49 50 printf(" E %.10E %.8e (987654321.123456789e12 for precision 10 & 8)\n",987654321.123456789e12,987654321.123456789e12); 51 u64const =0x7fffffffffffffffLL; 52 d =*((double *)((void *)(&u64const))); 53 printf(" E %.10E (NaN)\n",d); 54 u64const =(0xfff0000000000000LL); 55 d =*(double *)(void *)(&u64const); 56 printf(" E %.10E (-Inf)\n",d); 50 57 return; 51 58 }
Note:
See TracChangeset
for help on using the changeset viewer.