diff options
author | Gavin D. Howard <gavin@gavinhoward.com> | 2023-05-03 17:17:32 -0600 |
---|---|---|
committer | Gavin D. Howard <gavin@gavinhoward.com> | 2023-05-03 17:17:32 -0600 |
commit | b56c24c20e9d0835e809d8bf221e80048bc275b4 (patch) | |
tree | cc838176e6d08b257511f3a3ebfa75941b1974e1 | |
parent | c5e2018ba996b619843fc3818b1acc88313be797 (diff) | |
download | bc-b56c24c20e9d0835e809d8bf221e80048bc275b4.tar.gz |
Fix a bug reported by email
This bug is that bc will print a leading zero in scientific and
engineering modes, which makes no sense.
Signed-off-by: Gavin D. Howard <gavin@gavinhoward.com>
-rw-r--r-- | src/num.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -3515,8 +3515,9 @@ bc_num_print(BcNum* restrict n, BcBigDig base, bool newline) // Print the sign. if (BC_NUM_NEG(n)) bc_num_putchar('-', true); - // Print the leading zero if necessary. - if (BC_Z && BC_NUM_RDX_VAL(n) == n->len) + // Print the leading zero if necessary. We don't print when using + // scientific or engineering modes. + if (BC_Z && BC_NUM_RDX_VAL(n) == n->len && base != 0 && base != 1) { bc_num_printHex(0, 1, false, !newline); } |