GNU bug report logs - #24561
Unmathematical bc exponentiation behavior

Previous Next

Package: coreutils;

Reported by: "Martens, Tobias" <tobias.martens <at> stud.uni-goettingen.de>

Date: Wed, 28 Sep 2016 17:32:02 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 24561 in the body.
You can then email your comments to 24561 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#24561; Package coreutils. (Wed, 28 Sep 2016 17:32:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Martens, Tobias" <tobias.martens <at> stud.uni-goettingen.de>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 28 Sep 2016 17:32:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Martens, Tobias" <tobias.martens <at> stud.uni-goettingen.de>
To: "bug-coreutils <at> gnu.org" <bug-coreutils <at> gnu.org>
Subject: Unmathematical bc exponentiation behavior
Date: Wed, 28 Sep 2016 15:48:27 +0000
[Message part 1 (text/plain, inline)]
Hey,

echo "-(1)^2" | bc
1

I would have expected -1. This behavior is unmathematical and very confusing, because otherwise bc acts quite logic.
Not sure if it is mandated by POSIX, atleast I could not find it to be in the section of exponentiation operator. Was this ever discussed?
Resolving "-(positive float)" to "(-1)*(positive float)" for intern calculation seems more appropriate to me and would give the desired results.

[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#24561; Package coreutils. (Wed, 28 Sep 2016 18:11:02 GMT) Full text and rfc822 format available.

Message #8 received at 24561 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: "Martens\, Tobias" <tobias.martens <at> stud.uni-goettingen.de>
Cc: 24561 <at> debbugs.gnu.org
Subject: Re: bug#24561: Unmathematical bc exponentiation behavior
Date: Wed, 28 Sep 2016 20:10:15 +0200
On Sep 28 2016, "Martens, Tobias" <tobias.martens <at> stud.uni-goettingen.de> wrote:

> echo "-(1)^2" | bc
> 1
>
> I would have expected -1. This behavior is unmathematical and very confusing, because otherwise bc acts quite logic.
> Not sure if it is mandated by POSIX

Unary - has higher precedence than ^, thus it is parsed as (-(1))^2.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-coreutils <at> gnu.org:
bug#24561; Package coreutils. (Wed, 28 Sep 2016 21:25:01 GMT) Full text and rfc822 format available.

Message #11 received at 24561 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: "Martens, Tobias" <tobias.martens <at> stud.uni-goettingen.de>,
 24561 <at> debbugs.gnu.org
Subject: Re: bug#24561: Unmathematical bc exponentiation behavior
Date: Wed, 28 Sep 2016 23:18:10 +0200
tag 24561 notabug
close 24561
stop


On 09/28/2016 05:48 PM, Martens, Tobias wrote:
> echo "-(1)^2" | bc
> 1

Andreas already gave the answer: operator precedence (see 'man bc').
Besides, bc(1) is not part of GNU coreutils, and a better address for
such a report would have been "bug-bc <at> gnu.org".
Therefore, I'm marking this as 'not a bug' here, closing the issue.

Have a nice day,
Berny




Information forwarded to bug-coreutils <at> gnu.org:
bug#24561; Package coreutils. (Thu, 29 Sep 2016 06:53:02 GMT) Full text and rfc822 format available.

Message #14 received at 24561 <at> debbugs.gnu.org (full text, mbox):

From: Erik Auerswald <auerswal <at> unix-ag.uni-kl.de>
To: "Martens, Tobias" <tobias.martens <at> stud.uni-goettingen.de>
Cc: 24561 <at> debbugs.gnu.org
Subject: Re: bug#24561: Unmathematical bc exponentiation behavior
Date: Thu, 29 Sep 2016 08:52:46 +0200
Hi Tobias,

On Wed, Sep 28, 2016 at 03:48:27PM +0000, Martens, Tobias wrote:
> echo "-(1)^2" | bc
> 1
> 
> I would have expected -1. This behavior is unmathematical and very
> confusing, because otherwise bc acts quite logic.

bc did exactly what you asked it to do. You probably meant to write:

    echo "-(1^2)" | bc

Thanks,
Erik
-- 
If it ain't broke, don't fix it.




Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 28 Oct 2018 07:03:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 24561 <at> debbugs.gnu.org and "Martens, Tobias" <tobias.martens <at> stud.uni-goettingen.de> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 28 Oct 2018 07:03:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 25 Nov 2018 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 210 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.