Changeset b0edf3b2 in mainline for src/debug/print.c
- Timestamp:
- 2005-09-09T11:59:25Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 38de8a5
- Parents:
- ba1b7393
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/debug/print.c
rba1b7393 rb0edf3b2 59 59 putchar('-'); 60 60 num=num*-1.0; 61 61 } 62 62 63 63 … … 65 65 print_str("Inf"); 66 66 return; 67 67 } 68 68 69 69 if ((modifier=='E')||(modifier=='e')) { … … 73 73 num = num / ((fmath_dpow(10.0,exponent))); 74 74 75 print_double(num,modifier+1,precision); / /modifier+1 = E => F or e => f75 print_double(num,modifier+1,precision); /* modifier+1 = E => F or e => f */ 76 76 putchar(modifier); 77 77 if (exponent<0) { 78 78 putchar('-'); 79 79 exponent*=-1; 80 80 } 81 81 print_number(exponent,10); 82 82 return; 83 83 } 84 84 85 //TODO: rounding constant - when we got fraction >= 0.5, we must increment last printed number 86 87 /* Here is problem with cumulative error while printing big double values -> we will divide 88 the number with a power of 10, print new number with better method for small numbers and then print decimal point at correct position */ 85 /* TODO: rounding constant - when we got fraction >= 0.5, we must increment last printed number */ 86 87 /* 88 * Here is a problem with cumulative error while printing big double values -> we will divide 89 * the number with a power of 10, print new number with better method for small numbers and 90 * then print decimal point at correct position. 91 */ 89 92 90 93 fmath_fint(fmath_get_decimal_exponent(num),&intval); … … 136 139 while (counter>0) { 137 140 putchar(buf[--counter]); 138 } ;141 } 139 142 return; 140 143 } … … 237 240 * digits). 238 241 * X As with 'x', but '0x' is prefixed. 242 * . The decimal number following period will be treated as precision 243 * for printing floating point numbers. One of 'e', 'E', 'f' or 'F' 244 * must follow. 245 * e The next variant argument is treated as double precision float 246 * and printed in exponent notation with only one digit before decimal point 247 * in specified precision. The exponent sign is printed as 'e'. 248 * E As with 'e', but the exponent sign is printed as 'E'. 249 * f The next variant argument is treated as double precision float 250 * and printed in decimal notation in specified precision. 251 * F As with 'f'. 239 252 * 240 253 * All other characters from fmt except the formatting directives … … 260 273 switch (c) { 261 274 262 263 264 275 /* control character */ 265 276 case '%': 277 precision = DEFAULT_DOUBLE_PRECISION; 278 if (fmt[i]=='.') { 279 precision=0; 280 c=fmt[++i]; 281 while((c>='0')&&(c<='9')) { 282 precision = precision*10 + c - '0'; 283 c=fmt[++i]; 284 } 285 } 266 286 267 precision = DEFAULT_DOUBLE_PRECISION; 268 if (fmt[i]=='.') { 269 precision=0; 270 c=fmt[++i]; 271 while((c>='0')&&(c<='9')) { 272 precision = precision*10 + c - '0'; 273 c=fmt[++i]; 274 } 275 276 } 277 278 switch (c = fmt[i++]) { 279 280 /* percentile itself */ 281 case '%': 282 break; 283 284 /* 285 * String and character conversions. 286 */ 287 case 's': 288 print_str(va_arg(ap, char_ptr)); 289 goto loop; 290 291 case 'c': 292 c = (char) va_arg(ap, int); 293 break; 294 295 /* 296 * Hexadecimal conversions with fixed width. 297 */ 298 case 'P': 299 print_str("0x"); 300 case 'p': 301 print_fixed_hex(va_arg(ap, __native), sizeof(__native)); 302 goto loop; 303 304 case 'Q': 305 print_str("0x"); 306 case 'q': 307 print_fixed_hex(va_arg(ap, __u64), INT64); 308 goto loop; 309 310 case 'L': 311 print_str("0x"); 312 case 'l': 313 print_fixed_hex(va_arg(ap, __native), INT32); 314 goto loop; 315 316 case 'W': 317 print_str("0x"); 318 case 'w': 319 print_fixed_hex(va_arg(ap, __native), INT16); 320 goto loop; 321 322 case 'B': 323 print_str("0x"); 324 case 'b': 325 print_fixed_hex(va_arg(ap, __native), INT8); 326 goto loop; 327 328 /* 329 * Floating point conversions. 330 */ 287 switch (c = fmt[i++]) { 288 289 /* percentile itself */ 290 case '%': 291 break; 292 293 /* 294 * String and character conversions. 295 */ 296 case 's': 297 print_str(va_arg(ap, char_ptr)); 298 goto loop; 299 300 case 'c': 301 c = (char) va_arg(ap, int); 302 break; 303 304 /* 305 * Hexadecimal conversions with fixed width. 306 */ 307 case 'P': 308 print_str("0x"); 309 case 'p': 310 print_fixed_hex(va_arg(ap, __native), sizeof(__native)); 311 goto loop; 312 313 case 'Q': 314 print_str("0x"); 315 case 'q': 316 print_fixed_hex(va_arg(ap, __u64), INT64); 317 goto loop; 318 319 case 'L': 320 print_str("0x"); 321 case 'l': 322 print_fixed_hex(va_arg(ap, __native), INT32); 323 goto loop; 324 325 case 'W': 326 print_str("0x"); 327 case 'w': 328 print_fixed_hex(va_arg(ap, __native), INT16); 329 goto loop; 330 331 case 'B': 332 print_str("0x"); 333 case 'b': 334 print_fixed_hex(va_arg(ap, __native), INT8); 335 goto loop; 336 337 /* 338 * Floating point conversions. 339 */ 340 case 'F': 341 print_double(va_arg(ap, double),'F',precision); 342 goto loop; 343 344 case 'f': 345 print_double(va_arg(ap, double),'f',precision); 346 goto loop; 331 347 332 case 'F': 333 print_double(va_arg(ap, double),'F',precision); 334 goto loop; 335 336 case 'f': 337 print_double(va_arg(ap, double),'f',precision); 338 goto loop; 348 case 'E': 349 print_double(va_arg(ap, double),'E',precision); 350 goto loop; 351 case 'e': 352 print_double(va_arg(ap, double),'e',precision); 353 goto loop; 339 354 340 case 'E': 341 print_double(va_arg(ap, double),'E',precision); 342 goto loop; 343 case 'e': 344 print_double(va_arg(ap, double),'e',precision); 345 goto loop; 346 347 /* 348 * Decimal and hexadecimal conversions. 349 */ 350 case 'd': 351 print_number(va_arg(ap, __native), 10); 352 goto loop; 353 354 case 'X': 355 print_str("0x"); 356 case 'x': 357 print_number(va_arg(ap, __native), 16); 358 goto loop; 355 /* 356 * Decimal and hexadecimal conversions. 357 */ 358 case 'd': 359 print_number(va_arg(ap, __native), 10); 360 goto loop; 361 362 case 'X': 363 print_str("0x"); 364 case 'x': 365 print_number(va_arg(ap, __native), 16); 366 goto loop; 359 367 360 361 362 363 364 365 368 /* 369 * Bad formatting. 370 */ 371 default: 372 goto out; 373 } 366 374 367 375 default: putchar(c);
Note:
See TracChangeset
for help on using the changeset viewer.