Discussion:
bug#30453: Bug in BC calculator version 1.07.1
(too old to reply)
Thomas Bracken
2018-02-14 06:52:22 UTC
Permalink
Hello,

Your BC calculator does not do any truncation for the scale value

when it does a multiplication.  See example below.

It works fine on division, but not on multiplication.

Cheers!

Tom Bracken

[***@HP6005computer1 ~]$ bc
bc 1.07.1
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free
Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
scale = 5
56.4325435 / 6.3408340583467346436
8.89986
56.4325435 * 6.3408340583467346436
357.82939_38239336408579_
56.4325435 * 6.3408340583467346436 / 1
357.82939
quit
[***@HP6005computer1 ~]$




--
Martin Møller Skarbiniks Pedersen
2018-02-14 22:33:29 UTC
Permalink
This is not a bug.
From the man-page:

$ man bc | fgrep -A5 "expr * expr"
expr * expr
The result of the expression is the product of the two
expressions.

expr / expr
The result of the expression is the quotient of
the two expressions. The scale of the result is the value of the
variable
scale.


So expr * expr is not scaled but expr / expr is scaled.

Regards
Martin
Post by Thomas Bracken
Hello,
Your BC calculator does not do any truncation for the scale value
when it does a multiplication. See example below.
It works fine on division, but not on multiplication.
This is not a bug.
From the man-page:

$ man bc | fgrep -A5 "expr * expr"
expr * expr
The result of the expression is the product of the two
expressions.

expr / expr
The result of the expression is the quotient of
the two expressions. The scale of the result is the value of the
variable
scale.


Regards
Martin
Assaf Gordon
2018-10-30 02:46:34 UTC
Permalink
tags 30453 notabug
close 30453
stop

(triaging old bugs)
Post by Martin Møller Skarbiniks Pedersen
This is not a bug.
$ man bc | fgrep -A5 "expr * expr"
expr * expr
The result of the expression is the product of the two
expressions.
expr / expr
The result of the expression is the quotient of
the two expressions. The scale of the result is the value of the
variable
scale.
as bc(1) is not part of GNU coreutils,
I'm closing this bug.

-assaf

Loading...