@@ -654,21 +654,53 @@ std::string Reformat::format(int row, int col, const std::string& in_text) const
654654
655655 if (fmt.m_reformat_digits >= 0 )
656656 {
657- if (fmt.m_reformat_digits != 3 )
658- OUT_THROW (" Error, currently only digits=3 is implemented." );
659-
660- if (v < 1 ) {
661- // not 3: need leading 0.
662- oss << std::fixed << std::setprecision (3 );
657+ if (fmt.m_reformat_digits == 2 ) {
658+ if (v < 1 ) {
659+ // not 2: need leading 0.
660+ oss << std::fixed << std::setprecision (2 );
661+ }
662+ else if (v < 10 ) {
663+ oss << std::fixed << std::setprecision (1 );
664+ }
665+ else {
666+ oss << std::fixed << std::setprecision (0 );
667+ }
663668 }
664- else if (v < 10 ) {
665- oss << std::fixed << std::setprecision (2 );
669+ else if (fmt.m_reformat_digits == 3 ) {
670+ if (v < 1 ) {
671+ // not 3: need leading 0.
672+ oss << std::fixed << std::setprecision (3 );
673+ }
674+ else if (v < 10 ) {
675+ oss << std::fixed << std::setprecision (2 );
676+ }
677+ else if (v < 100 ) {
678+ oss << std::fixed << std::setprecision (1 );
679+ }
680+ else {
681+ oss << std::fixed << std::setprecision (0 );
682+ }
666683 }
667- else if (v < 100 ) {
668- oss << std::fixed << std::setprecision (1 );
684+ else if (fmt.m_reformat_digits == 4 ) {
685+ if (v < 1 ) {
686+ // not 4: need leading 0.
687+ oss << std::fixed << std::setprecision (4 );
688+ }
689+ else if (v < 10 ) {
690+ oss << std::fixed << std::setprecision (3 );
691+ }
692+ else if (v < 100 ) {
693+ oss << std::fixed << std::setprecision (2 );
694+ }
695+ else if (v < 1000 ) {
696+ oss << std::fixed << std::setprecision (1 );
697+ }
698+ else {
699+ oss << std::fixed << std::setprecision (0 );
700+ }
669701 }
670702 else {
671- oss << std::fixed << std::setprecision ( 0 );
703+ OUT_THROW ( " Error, currently only digits={2,3,4} is implemented. " );
672704 }
673705 }
674706 else
0 commit comments