- Timestamp:
- May 4, 2026, 12:11:43 PM (9 days ago)
- Branches:
- master
- Children:
- 9375148
- Parents:
- bb1eabc
- File:
-
- 1 edited
-
libcfa/src/iostream.cfa (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.cfa
rbb1eabc r244335b 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 3 22:02:37202613 // Update Count : 2 27112 // Last Modified On : Mon May 4 12:00:48 2026 13 // Update Count : 2310 14 14 // 15 15 … … 599 599 #define SUFFIXES_END (SUFFIXES_START + (int)((sizeof(suffixes) / sizeof(char *) - 1) * 3)) 600 600 601 // Float-point numbers without a fraction are always printed with a decimal point to reflect the constant type. 602 // Programmers must explicitly disable printing the decimal point for values with no fraction using manipulator nodp. 603 // printf supports printing the decimal point using flag #. However specifier g is broken with #. 604 // 605 // printf( "%g %#g %g %#g\n", 4., 4., 4.5, 4.5 ); 606 // 4 4.00000 4.5 4.50000 607 // 608 // when # is specified, g incorrectly prints 6 significant digits. As a result, # cannot be used to force printing of 609 // the decimal point. Instead, any missing decimal point is manually added. 610 601 611 #define PRINT_WITH_DP2( os, format, ... ) \ 602 612 { \ … … 605 615 if ( isfinite( f.val ) && ! f.flags.nobsdp ) { /* if number, print decimal point when no fraction or exponent */ \ 606 616 for ( i = 0; i < len && buf[i] != '.' && buf[i] != 'e' && buf[i] != 'E' && \ 607 buf[i] != 'p' && buf[i] != 'P'; i += 1 ); /* decimal point or scientific ? */ \617 buf[i] != 'p' && buf[i] != 'P'; i += 1 ); /* decimal point or scientific ? */ \ 608 618 if ( i == len ) { \ 609 619 if ( ! f.flags.left ) { \ … … 619 629 } else { \ 620 630 int exp10, len2; \ 621 eng( f.val, f.pc, exp10 ); /* changes arguments */ \631 eng( f.val, f.pc, exp10 ); /* changes arguments */ \ 622 632 /* printf( "%g %d %d %d %s\n", f.val, f.wd, f.pc, exp10, format ); */ \ 623 633 if ( ! f.flags.left && f.wd > 1 ) { \ … … 657 667 \ 658 668 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); \ 659 char fmtstr[sizeof(DFMTP) + 8]; /* sizeof includes '\0' */ \669 char fmtstr[sizeof(DFMTP) + 8]; /* sizeof includes '\0' */ \ 660 670 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ 661 671 else memcpy( &fmtstr, DFMTP, sizeof(DFMTP) ); \ 662 int star = 5; /* position before first '*' */ \672 int star = 5; /* position before first '*' */ \ 663 673 \ 664 674 /* Insert flags into spaces before '*', from right to left. */ \ … … 666 676 if ( f.flags.sign ) { fmtstr[star] = '+'; star -= 1; } \ 667 677 if ( f.flags.pad0 ) { fmtstr[star] = '0'; star -= 1; } \ 668 fmtstr[star] = '\''; star -= 1; /* locale */ \ 678 if ( f.base == 'f' && f.base == 'F' && f.base == 'g' && f.base == 'G' ) { fmtstr[star] = '\''; star -= 1; } /* locale only for f andg */ \ 679 else if ( ! f.flags.nobsdp && (f.base == 'a' || f.base == 'A') ) { fmtstr[star] = '#'; star -= 1; } /* hex special case to get decimal point */ \ 669 680 fmtstr[star] = '%'; \ 670 681 \ 671 if ( ! f.flags.pc ) { /* no precision */ \672 fmtstr[sizeof(DFMTNP)-2] = f.base; /* sizeof includes '\0' */ \673 /* printf( " %g %d %s\n", f.val, f.wd, &fmtstr[star] ); */ \682 if ( ! f.flags.pc ) { /* no precision */ \ 683 fmtstr[sizeof(DFMTNP)-2] = f.base; /* sizeof includes '\0' */ \ 684 /* printf( "[%g %c %d %s]\n", f.val, f.base, f.wd, &fmtstr[star] ); */ \ 674 685 PRINT_WITH_DP2( os, &fmtstr[star], f.wd, f.val ) \ 675 } else { /* precision */ \676 fmtstr[sizeof(DFMTP)-2] = f.base; /* sizeof includes '\0' */ \677 /* printf( " %g %d %d %s\n", f.val, f.wd, f.pc, &fmtstr[star] ); */ \686 } else { /* precision */ \ 687 fmtstr[sizeof(DFMTP)-2] = f.base; /* sizeof includes '\0' */ \ 688 /* printf( "[%g %c %d %d %s]\n", f.val, f.base, f.wd, f.pc, &fmtstr[star] ); */ \ 678 689 PRINT_WITH_DP2( os, &fmtstr[star], f.wd, f.pc, f.val ) \ 679 690 } /* if */ \
Note:
See TracChangeset
for help on using the changeset viewer.