The following issue has been SUBMITTED. 
====================================================================== 
http://austingroupbugs.net/view.php?id=1079 
====================================================================== 
Reported By:                tobiasm
Assigned To:                ajosey
====================================================================== 
Project:                    1003.1(2008)/Issue 7
Issue ID:                   1079
Category:                   Shell and Utilities
Type:                       Enhancement Request
Severity:                   Editorial
Priority:                   normal
Status:                     Under Review
Name:                       Tobias Martens 
Organization:                
User Reference:              
Section:                    bc 
Page Number:                - 
Line Number:                - 
Interp Status:              --- 
Final Accepted Text:         
====================================================================== 
Date Submitted:             2016-10-05 23:40 UTC
Last Modified:              2016-10-05 23:40 UTC
====================================================================== 
Summary:                    focus on bc being an arithmetic language
Description: 
Due to the specified precedence of operators in bc, where unary - is higher
than ^ (exponentiation operator), the result of

-(1+1)^2

will be 4, unlike any other calculator or arithmetic language I have
encountered. I see the advantage this may have, for example (since bc often
takes external input) when piping variable to bc in shell:

var=-2
echo "${var}^2" | bc

will result in 4, which may seem intuitive and mathematical to someone who
is not aware of how shell processes the string. Personally, while I
encourage allowing a intuitive approach, this shall not influence common
arithmetic as given by the example above. 
Moreover, the apparent advantage is destroyed by a simple subtraction:

echo "3-${var}" | bc

produces a syntax error (in GNU bc 1.06.95), likely due to the
specification of ++ and -- (unary increment and decrement). Note how the
same command works for the corresponding addition.
Again, other arithmetic languages will compute the expression 3--2
correctly to 5, only bc, sticking with programming languages' syntax and
behaviour, will not be able to do so.

Let me conclude with how bc is called in the specification:
"bc - arbitrary-precision arithmetic language"
Desired Action: 
First I want to invite you to discuss a shift of bc to a more arithmetic
language (in the common sense) with me, occurring problems and
possibilities.

In my opinion, the following actions would move bc to a arithmetic language
as known from calculators and other arithmetic languages all over the
world:

-switch precedence of unary - and ^. 

-remove unary increment and decrement. 
This may sound drastic, but those operators are shortcut programming
syntax, not arithemtic. There is no need for these shortcuts in bc because
they aren't used nearly as often as in programming languages. They are
redundant and only add unnecessary complexity and confusion when simple
subtractions fail.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2016-10-05 23:40 tobiasm        New Issue                                    
2016-10-05 23:40 tobiasm        Status                   New => Under Review 
2016-10-05 23:40 tobiasm        Assigned To               => ajosey          
2016-10-05 23:40 tobiasm        Name                      => Tobias Martens  
2016-10-05 23:40 tobiasm        Section                   => bc              
2016-10-05 23:40 tobiasm        Page Number               => -               
2016-10-05 23:40 tobiasm        Line Number               => -               
======================================================================


Reply via email to