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 <[email protected]>
This commit is contained in:
Gavin D. Howard 2023-05-03 17:17:32 -06:00
parent c5e2018ba9
commit b56c24c20e
Signed by: gavin
GPG Key ID: 93D31C8CA4AB6C63
1 changed files with 3 additions and 2 deletions

View File

@ -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);
}