LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-07-2023, 09:20 PM   #1
kernelhead
Member
 
Registered: Jun 2022
Posts: 247

Rep: Reputation: 5
Ubuntu's Calculator is wrong - ???


My friend who is a genius at math says the answer to this is 1. Others say it is 36. Even my Ubuntu's built in calculator says it's 36.

What gives?
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2023-04-07 22-13-34.png
Views:	105
Size:	23.0 KB
ID:	40760  
 
Old 04-07-2023, 10:40 PM   #2
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,392

Rep: Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594
The calculator is doing the operations in the wrong order. The answer is 1
48/8(14-8)=
48/(112-64)=
48/48=
1

Do note I went to school before new-math came out.
 
1 members found this post helpful.
Old 04-07-2023, 10:41 PM   #3
kernelhead
Member
 
Registered: Jun 2022
Posts: 247

Original Poster
Rep: Reputation: 5
Quote:
Originally Posted by colorpurple21859 View Post
The calculator is doing the operations in the wrong order. The answer is 1
48/8(14-8)=
48/(112-64)=
48/48=
1

Do note I went to school before new-math came out.

I tried to select every option in the calculators menus and couldn't get it to come up with any answer but 36.

Is this not a bit emabrrasing that Ubuntu comes with this calculator ???
 
Old 04-07-2023, 10:49 PM   #4
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,392

Rep: Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594
this works:
48÷(8(14−8))
otherwise the calculator does 48÷8(14−8) the same as (48÷8)×(14−8)

Last edited by colorpurple21859; 04-07-2023 at 10:55 PM.
 
Old 04-07-2023, 10:58 PM   #5
kernelhead
Member
 
Registered: Jun 2022
Posts: 247

Original Poster
Rep: Reputation: 5
Quote:
Originally Posted by colorpurple21859 View Post
this works:
48÷(8(14−8))
otherwise the calculator does 48÷8(14−8) the same as (48÷8)×(14−8)
Do others think that this should be corrected in the calculator app - that comes with Ubuntu ?
 
Old 04-07-2023, 11:25 PM   #6
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,392

Rep: Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594
I would think so, from the help menu you could go to the calculator website and file a bug report. I've never entered parenthesis on a calculator just numbers.
 
Old 04-07-2023, 11:49 PM   #7
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
Oh god not this again...

It's ambiguous because you failed to put in enough brackets. Here's one of the more serious discussions:

https://math.stackexchange.com/quest...t-is-48-div293

Last edited by dugan; 04-07-2023 at 11:54 PM.
 
1 members found this post helpful.
Old 04-08-2023, 09:03 AM   #8
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,392

Rep: Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594
No surprise here, just never have used () on a calculator. I do remember coming across something similar many years ago on a handheld calculator where the answer was different based on how the numbers were entered.
 
Old 04-08-2023, 11:42 AM   #9
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
You specifically punched in:

Code:
48÷8(14-8)
FWIW, I get 1, and I think most people would. But how does the calculator see it?

Obviously, it expands it to:

Code:
48 ÷ 8 * (14 - 8)
It's the same thing, but I assume that makes it more clear what the problem is.

Note that this is not the same as:

Quote:
48/8(14-8)

Last edited by dugan; 04-08-2023 at 11:56 AM.
 
1 members found this post helpful.
Old 04-08-2023, 11:59 AM   #10
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Garbage in garbage out? Express your formula correctly or expect failure. You lose nothing expressing things properly.
 
2 members found this post helpful.
Old 04-08-2023, 12:56 PM   #11
kernelhead
Member
 
Registered: Jun 2022
Posts: 247

Original Poster
Rep: Reputation: 5
hmm, all the people in Ubuntu forum think the answer is 36

https://ubuntuforums.org/showthread.php?t=2485746
 
Old 04-08-2023, 01:05 PM   #12
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
When I was in school it was "Bless My Dear Aunt Sally" or: Brackets, Multiplication, Division, Addition, Subtraction. So in this case I'd do the bracketed expression first, that's 14-8=6. Then the multiplication of 8 times that 6 which is 48. Then I would do the final division and get one.
But, on the other hand, if the 8 is seen as part of the bracketed expression then it still goes in that order, surely?
Edit: Sorry read that thread and it seems that mathematicians work from left to right now?
"2) evaluate multiplication and division proceeding left to right.
3) evaluate additions and subtractions proceeding left to right."

Last edited by 273; 04-08-2023 at 01:07 PM.
 
Old 04-08-2023, 01:13 PM   #13
rclark
Member
 
Registered: Jul 2008
Location: Montana USA
Distribution: KUbuntu, Fedora (KDE), PI OS
Posts: 496

Rep: Reputation: 182Reputation: 182
Of course if we just use a proper RPN notation calculator (say 'free42dec', a HP 42S simulator)... No problem . Otherwise if using new math and in doubt, put in () to explicitly express what you are trying to do. Ambiguity goes away.

Last edited by rclark; 04-08-2023 at 01:15 PM.
 
1 members found this post helpful.
Old 04-08-2023, 01:18 PM   #14
kernelhead
Member
 
Registered: Jun 2022
Posts: 247

Original Poster
Rep: Reputation: 5
My friend says this about the equation:

The full analysis of this situation is now clear: it depends on whether you think like a programmer, or a mathematician.

C, and, through its influence over the decades, apparently many other languages as well -- clearly including Perl,as shown here -- is documented and standardized as evaluating expressions left to right, except for performing parenthetical expression evaluation first and bottom-up (or deepest-first). This is just a different rule from what a mathematician or school teacher would consider the proper rules of arithmetic, namely PEMDAS.

Clearly, what's happening here is that all the participants in this discussion are programmers, who have grown up WTF commuters, physicians grown up with organic, are accustomed to the C rules and thus really do consider 36 "the right answer" because that's what the official programming language rules give you.

However, I submit that, while that is certainly the expected result of the calculation in a organizational language, it is, nonetheless, not the "right answer" that someone who knows how to correctly perform arithmetic should get when doing the calculation "with pencil and paper." Outside of program source code, the rules of PEMDAS are in force and the real-world right answer is 1.

The unfortunate fact, though, is that several generations of programmers have now grown up internalizing C-style left-to-right evacuation rules, to the point where they now consistently fail to recognize that exposing that method to the outside would, such as on the display and workings of a calculator app, is a semantic error that muddies the waters and perpetuates and spreads this dangerous misperception.

If you'd like, you can add that your math-genius friend says there is no room for argument here: these are the facts, and their calculator apps, as they stand today are suitable only for programmers, not for the general public. For the general public, an expression evaluator that specifically implements PEMDAS should be used instead of C-like left-to-right evaluation. I would be happy to try to write said PEMDAS evaluator.

The addition of another set of parentheses forces the language to evaluate the entire right-hand side of the division FIRST, producing a denominator of 48 exactly as per PEMDAS. The effect is, in essence, to force the language/code to perfrom M before D, whereas in strict left-to-right order, in the original expression, the interpreter encounters, and therefore performs, D before M.

Last edited by kernelhead; 04-08-2023 at 01:25 PM.
 
2 members found this post helpful.
Old 04-08-2023, 01:22 PM   #15
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by kernelhead View Post
My friend says this about the equation:

The full analysis of this situation is now clear: it depends on whether you think like a programmer, or a mathematician.

C, and, through its influence over the decades, apparently many other languages as well -- clearly including Perl,as shown here -- is documented and standardized as evaluating expressions left to right, except for performing parenthetical expression evaluation first and bottom-up (or deepest-first). This is just a different rule from what a mathematician or school teacher would consider the proper rules of arithmetic, namely PEMDAS.

Clearly, what's happening here is that all the participants in this discussion are programmers, who have grown up WTF commuters, physicians grown up with organic, are accustomed to the C rules and thus really do consider 36 "the right answer" because that's what the official programming language rules give you.

However, I submit that, while that is certainly the expected result of the calculation in a organizational language, it is, nonetheless, not the "right answer" that someone who knows how to correctly perform arithmetic should get when doing the calculation "with pencil and paper." Outside of program source code, the rules of PEMDAS are in force and the real-world right answer is 1.

The unfortunate fact, though, is that several generations of programmers have now grown up internalizing C-style left-to-right evacuation rules, to the point where they now consistently fail to recognize that exposing that method to the outside would, such as on the display and workings of a calculator app, is a semantic error that muddies the waters and perpetuates and spreads this dangerous misperception.
The worrying thing is that I googled "evaluate multiplication and division proceeding left to right." and it comes up on some Mathematics For Dummies thing as a mathematical rule.
I've been trying to think of a way the left to right could fail but my maths isn't good enough (and probably never was) but it strikes me that finding the result of simultaneous equations or similar on paper could be broken by this. I still think the answer is to be clearer and nest things in parentheses as they should be evaluated but I wonder whether this attitude is bad for maths?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Calculator N+ is an open source scientific calculator for your smartphone LXer Syndicated Linux News 0 11-27-2019 06:21 AM
Ubuntu calculator problem (or is it just me?) cajunchief Linux - Laptop and Netbook 5 09-27-2011 10:24 AM
LXer: Improved Calculator App in Ubuntu 10.10 LXer Syndicated Linux News 0 07-14-2010 10:50 PM
I can't figure out what is wrong with this code-its a calculator written in c AceofSpades19 Programming 17 03-04-2007 01:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration