bug#24561: Unmathematical bc exponentiation behavior
Hi Tobias, On Wed, Sep 28, 2016 at 03:48:27PM +, 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.
bug#24561: Unmathematical bc exponentiation behavior
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...@gnu.org". Therefore, I'm marking this as 'not a bug' here, closing the issue. Have a nice day, Berny
bug#24561: Unmathematical bc exponentiation behavior
On Sep 28 2016, "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. > Not sure if it is mandated by POSIX Unary - has higher precedence than ^, thus it is parsed as (-(1))^2. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
bug#24561: Unmathematical bc exponentiation behavior
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.