Mercurial > octave
comparison libinterp/interpfcn/pr-output.cc @ 16339:0c340bf413d7
allow exponent in output to always have 3 digits
* pr-output.cc (set_real_format): Always allow 3 digits for exponent.
Increase field width by 1 for engineering and scientific formats.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 19 Mar 2013 20:51:27 -0400 |
parents | 0303fda3e929 |
children |
comparison
equal
deleted
inserted
replaced
16338:8aeb5d5c3747 | 16339:0c340bf413d7 |
---|---|
603 { | 603 { |
604 if (print_g) | 604 if (print_g) |
605 fmt = float_format (); | 605 fmt = float_format (); |
606 else | 606 else |
607 { | 607 { |
608 int ex = 4; | 608 // e+ddd |
609 if (digits > 100) | 609 int ex = 5; |
610 ex++; | |
611 | 610 |
612 if (print_eng) | 611 if (print_eng) |
613 { | 612 { |
614 fw = 4 + prec + ex; | 613 // -ddd. |
614 fw = 5 + prec + ex; | |
615 if (inf_or_nan && fw < 6) | 615 if (inf_or_nan && fw < 6) |
616 fw = 6; | 616 fw = 6; |
617 fmt = float_format (fw, ex, prec - 1, std::ios::fixed); | 617 fmt = float_format (fw, ex, prec - 1, std::ios::fixed); |
618 } | 618 } |
619 else | 619 else |
620 { | 620 { |
621 fw = 2 + prec + ex; | 621 // -d. |
622 fw = 3 + prec + ex; | |
622 if (inf_or_nan && fw < 4) | 623 if (inf_or_nan && fw < 4) |
623 fw = 4; | 624 fw = 4; |
624 fmt = float_format (fw, prec - 1, std::ios::scientific); | 625 fmt = float_format (fw, ex, prec - 1, std::ios::scientific); |
625 } | 626 } |
626 } | 627 } |
627 | 628 |
628 if (print_big_e) | 629 if (print_big_e) |
629 fmt.uppercase (); | 630 fmt.uppercase (); |