From 91a57a7e417b3de402da5793f91029a4f45d1679 Mon Sep 17 00:00:00 2001 From: otto Date: Sat, 2 Dec 2017 12:43:18 +0000 Subject: [PATCH] make 0Z do what the original dc and gnu bcc do; ok tom@ --- usr.bin/dc/bcode.c | 4 ++-- usr.bin/dc/dc.1 | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c index adc132841de..3c13de8f38e 100644 --- a/usr.bin/dc/bcode.c +++ b/usr.bin/dc/bcode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcode.c,v 1.57 2017/12/01 19:04:15 otto Exp $ */ +/* $OpenBSD: bcode.c,v 1.58 2017/12/02 12:43:18 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek @@ -705,7 +705,7 @@ count_digits(const struct number *n) int bits; if (BN_is_zero(n->number)) - return n->scale ? n->scale : 1; + return n->scale; int_part = BN_new(); bn_checkp(int_part); diff --git a/usr.bin/dc/dc.1 b/usr.bin/dc/dc.1 index efcd2ce0e51..c5e1ab8f7e4 100644 --- a/usr.bin/dc/dc.1 +++ b/usr.bin/dc/dc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dc.1,v 1.32 2017/12/02 07:35:46 otto Exp $ +.\" $OpenBSD: dc.1,v 1.33 2017/12/02 12:43:18 otto Exp $ .\" .\" Copyright (C) Caldera International Inc. 2001-2002. .\" All rights reserved. @@ -313,6 +313,7 @@ Replaces the number on the top of the stack with its length. The length of a string is its number of characters. The length of a number is its number of digits, not counting the minus sign and decimal point. +The length of a zero value is its scale. .It Ic z The stack level is pushed onto the stack. .It Cm \&[ Ns ... Ns Cm \&] -- 2.20.1