Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I truly do wander if something bad could happen, like a bridge collapse or a rocket explode, due to using the wrong standard - or has it already happened?
At the time, some pilots were being trained to follow instructions from the Traffic Collision Avoidance System, and other pilots were being trained to ignore TCAS and follow instructions from Air Traffic Control. A seemingly small thing, but it lead to tragedy in this case.
I would hope engineers are trained the same way around the globe... Otherwise you're right: It could be a disaster waiting to happen.
I offered the 2 online calculators as an argument to the statement "Calculators around the world all work the same, in order of precedence left to right."
& to show that calculators around the world don't all work in the same way.
If the 2 calculators didn't show their work on screen, like the Ubuntu calculator doesn't, then wouldn't we conclude that multiplication takes priority over division. And the fact that the 2 online calculators do show their work, I don't think it is a definite conclusion, either, that they aren't making multiplication a priority, because they are still doing the "10•2" on the bottom before considering the 20 on top (& before considering the division sign)...
The answer is based on the operator precedence. Unfortunately you cannot find the relevant part on the wiki page: https://en.wikipedia.org/wiki/Order_of_operations.
We have an additional operation, called implied (or implicit) multiplication, see for example here: https://www.themathdoctors.org/order...ultiplication/.
This is what was missing. I think this rule is not really implemented in some calculators....
I truly do wander if something bad could happen, like a bridge collapse or a rocket explode, due to using the wrong standard - or has it already happened? We can all hope that plenty of parenthesis are being deployed to prevent this!
Dreamliners have four main GCUs associated with the engine mounted generators. If all of them were powered up at the same time, "after 248 days of continuous power, all four GCUs will go into failsafe mode at the same time, resulting in a loss of all AC electrical power regardless of flight phase.
I checked the mode after the 1st time I got those odd results. It was the correct mode: Simple.
I get 36 with the multiplication sign between 48/8 and (14-8).
I had a link, but I got so disgusted when reviewing kernelhead's friend's confidently-wrong stupidity that I decided not to post it.
For the record, the correct answer is that the question is malformed. The link was valuable as a discussion how what is essentially the applied math community agreed to deal with that, but I knew that some people here would try to take it as more than that.
Thanks for the post anyway dugan, it gave me the opportunity to read the entire thread again, to which I add the following comments.
I have no relevant degrees but have always had a love of math and physics myself, having studied extensively and enjoyed a successful career directly related to that study.
It seems to me the equation as originally posted is simply ambiguous, the ambiguity being whether or not the parenthesized term is part of the denominator or not (post #69 and others). Being ambiguous, neither form can be said to be correct and the other incorrect. If there is an actual intent that it be one way or the other it is up to the person originating the expression to force that ordering by parenthesis.
I was taught, or at least learned in public school in the 1960's that multiplication and division have the same precedence, resolved by left-to-right ordering in absence of parenthesis.
I first encountered the expression PEMDAS when educating my own children (all home schooled), and understood it to mean:
Code:
Parenthesis, Exponents, Multiplication and Division, Addition and Subtraction
... and taught it that way. (And one of the refs previously cited in this thread presents it exactly this way).
Requiring that PEMDAS specifies multiplication to have a higher precedence than division without the same requirement for addition and subtraction seems somehow disingenuous.
I learned my first advanced math using a slide rule, and was always keenly aware that it was up to me to force precedence in written expressions if there were any reasonable possibility that they might be understood differently by others. Had 48/8(14-8) ever arisen and led to differing results one would have just asked what was intended. I cannot imagine one insisting theirs was correct and the other wrong in such a case and arguing about it.
We no longer use slide rules but have a variety of wonderful electronic devices to solve our equations, but the same operator discipline must apply. Unless we we are going to insist that every device conforms to a single input expression format and produces the identical output, we must recognize that it is up to the operator to assure that the input correctly expresses their intent within the limitations of the given device. Nothing else seems reasonable.
The argument that this supposed error derives from the C programming language seems just silly to me.
The main argument I've seen for doing it the other way (both in this thread and in the link I held back) is that 8(14 - 8) and 8 * (14 - 8) are not the same. That's what the nonsense about "juxtaposition" is about.
I first encountered the expression PEMDAS when educating my own children (all home schooled), and understood it to mean:
Code:
Parenthesis, Exponents, Multiplication and Division, Addition and Subtraction
... and taught it that way. (And one of the refs previously cited in this thread presents it exactly this way).
Requiring that PEMDAS specifies multiplication to have a higher precedence than division without the same requirement for addition and subtraction seems somehow disingenuous.
The problem is that this PEMDAS is wrong. We have an additional operation (as it was already explained in post #77). That is the implied/implicit multiplication. It is not mentioned on the wiki page you linked, therefore that wiki page is incomplete too. This operation has a relatively high precedence: PEIMDAS
You cannot discuss this question without knowing the existence of this additional possibility (just because it is all about that I). And obviously you cannot find the correct answer without that (that will lead to confusion and misunderstanding).
What is really surprising: this I operation is very little known, they don't teach it at school and even those who work with it (=make calculators or teach it) don't know anything about it.
Even more interesting is that this I operation is all around us, a part of our everyday life. You always speak about 2 apples, 5 tickets or similar. And if you have 30 eggs and you want to put them in baskets (which can hold 10 eggs), you realize: 30e/10e = 3, and it will never be 3e**2.
What is really surprising: this I operation is very little known, they don't teach it at school and even those who work with it (=make calculators or teach it) don't know anything about it.
Even more interesting is that this I operation is all around us, a part of our everyday life. You always speak about 2 apples, 5 tickets or similar. And if you have 30 eggs and you want to put them in baskets (which can hold 10 eggs), you realize: 30e/10e = 3, and it will never be 3e**2.
I will reserve comments on implied multiplication itself for another post, if at all, but the above is contrived, and is just wrong.
"30 eggs" does not involve multiplication of number, 30, and physical object, eggs. What would it even mean to multiply a number and an egg?
If you write 30e to mean 30 eggs then the only possible way to interpret it is 30 times the unit quantifier, an egg, the unit always and by definition being 1 (think unit vectors, for example).
So, for this case e explicitly and always equals 1, the unit of "egg", and 30*1/10*1 = 3, a pure number, not an egg, no matter how you parenthesize it, with no special precedence rules necessary.
This illustrates the problem with contrivances such as the original problem in this thread - contrivances inevitably beget contrivances and we all lose our way!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.