Changeset 51022e9b in mainline for src/debug/print.c
- Timestamp:
- 2005-09-03T12:56:14Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 544b4bf
- Parents:
- ffcccf26
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/debug/print.c
rffcccf26 r51022e9b 42 42 #define DEFAULT_DOUBLE_BUFFER_SIZE 128 43 43 44 void print_double(double num, __u 16 precision)44 void print_double(double num, __u8 modifier, __u16 precision) 45 45 { 46 46 double intval,intval2; … … 49 49 unsigned char buf[DEFAULT_DOUBLE_BUFFER_SIZE]; 50 50 unsigned long in1,in2; 51 51 52 /* 52 53 if (fmath_is_nan(num)) { … … 61 62 62 63 num=fmath_abs(num); 64 65 if ((modifier=='E')||(modifier=='e')) { 66 intval2=fmath_fint(fmath_get_decimal_exponent(num),&intval); 67 exponent=intval; 68 if ((intval2<0.0)&&(exponent<0)) exponent--; 69 num = num / ((fmath_dpow(10.0,exponent))); 70 71 print_double(num,modifier+1,precision); //modifier+1 = E => F or e => f 72 putchar(modifier); 73 if (exponent<0) { 74 putchar('-'); 75 exponent*=-1; 76 } 77 print_number(exponent,10); 78 return; 79 } 80 63 81 64 82 /* … … 233 251 va_list ap; 234 252 char c; 235 253 254 __u16 precision; 255 236 256 va_start(ap, fmt); 237 257 … … 242 262 switch (c) { 243 263 264 265 244 266 /* control character */ 245 267 case '%': 268 269 precision = DEFAULT_DOUBLE_PRECISION; 270 if (fmt[i]=='.') { 271 precision=0; 272 c=fmt[++i]; 273 while((c>='0')&&(c<='9')) { 274 precision = precision*10 + c - '0'; 275 c=fmt[++i]; 276 } 277 278 } 279 246 280 switch (c = fmt[i++]) { 247 281 … … 299 333 300 334 case 'F': 335 print_double(va_arg(ap, double),'F',precision); 336 goto loop; 337 301 338 case 'f': 302 print_double(va_arg(ap, double),DEFAULT_DOUBLE_PRECISION); 303 goto loop; 339 print_double(va_arg(ap, double),'f',precision); 340 goto loop; 341 342 case 'E': 343 print_double(va_arg(ap, double),'E',precision); 344 goto loop; 345 case 'e': 346 print_double(va_arg(ap, double),'e',precision); 347 goto loop; 348 304 349 /* 305 350 * Decimal and hexadecimal conversions.
Note:
See TracChangeset
for help on using the changeset viewer.