aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin D. Howard <gavin@gavinhoward.com>2023-05-03 17:17:32 -0600
committerGavin D. Howard <gavin@gavinhoward.com>2023-05-03 17:17:32 -0600
commitb56c24c20e9d0835e809d8bf221e80048bc275b4 (patch)
treecc838176e6d08b257511f3a3ebfa75941b1974e1
parentc5e2018ba996b619843fc3818b1acc88313be797 (diff)
downloadbc-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.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/num.c b/src/num.c
index 2e32ce72..0a597072 100644
--- a/src/num.c
+++ b/src/num.c
@@ -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);
}