Poll
Question: So what's your final answer?
2 - 6 (33.3%)
288 - 10 (55.6%)
Go create something! - 2 (11.1%)
Total Voters: 18

Pages: 1 ... 3 4 [5] 6 7 8   Go Down
Author Topic: 48÷2(9+3) = ?  (Read 7462 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18740
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've just googled this and a site pointed out that implied multiplication has a higher precedence than division. For example, 2/5x would normally be interpreted as 2/(5x)

Reference?

I have seen it claimed that 3-1+5 equals -3 on the basis that you evaluate it as 3 - (1 + 5). The reason given is that BODMAS (or BIDMAS/BEDMAS) stands for Brackets, Exponents, Division, Multiplication, Addition, Subtraction. Therefore since addition is before subtraction you add 1 to 5, and then you subtract that from 3, giving -3.

However this is wrong. Multiplication/division, and addition/subtraction have equal priority and are evaluated left to right.
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18740
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Wikipedia:

Quote
Many programming languages use precedence levels that conform to the order commonly used in mathematics, though some, such as APL or Smalltalk, have no operator precedence rules (in APL evaluation is strictly right to left, in Smalltalk it's strictly left to right).


Not everybody agrees with that.

Yes, I see that.

Well the question is undefined then. Without specifying the base of the numbers, the domain in which we are working (eg. maths, APL, Smalltalk, C, Swahili, Martian) it cannot be answered.
Logged


Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17293
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
And that is the fundamental issue. Not everybody agrees with that.

Heck, we can't all even agree on which side of a road to drive on.  smiley-wink

Logged

Silly-con Valley, Ca, U.S.
Offline Offline
Sr. Member
****
Karma: 17
Posts: 420
Lernin' to tinker
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
And that is the fundamental issue. Not everybody agrees with that.

Heck, we can't all even agree on which side of a road to drive on.  smiley-wink


Now you're trying to confuse things with geometry.

Vehicle A belongs to me
Road B is whatever road vehicle A is on currently
Road B is bisected by line C
All roads belong to me
Therefore vehicle A may drive on either side of line C
Logged

10 PRINT CHR$(7)
20 GOTO 10

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Heck, we can't all even agree on which side of a road to drive on.
Depends which way you're travelling smiley-grin
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17293
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Heck, we can't all even agree on which side of a road to drive on.
Depends which way you're travelling smiley-grin

Well that would be my way or the highway.  smiley-wink
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

shouldn't it be following order of operations so that inside the parenthesis is first this would make it two, but as for the other approaches, I did not really get them.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 132
Posts: 6746
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I did not really get them.
It all boils down to whether you do the un-parthenthesized multiplication or division first:
48÷(2(9+3)) or (48÷2)(9+3)
and THAT depends on whether you believe that implied multiplication (2x) has a different precedence than explicit multiplication (2*x), whether there's an explicit precedence of multiplication vs division, and/or whether you believe in left-to-right evaluation or something else.  All of which are NOT consistently defined.
Logged

Newcastle, England
Offline Offline
Sr. Member
****
Karma: 3
Posts: 489
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've just googled this and a site pointed out that implied multiplication has a higher precedence than division. For example, 2/5x would normally be interpreted as 2/(5x)

48÷2(9+3) = y
If we say that (9+3) is x, then x = 12.
That makes it 48÷2x, or 48*(2*12)
2*12 is 24.
48÷24=2, so 2 is my answer.


Arduino disagrees though:

Code:
void setup(){
  Serial.begin(9600);
  Serial.print(48/2*(9+3));
}
void loop(){}

Serial output: 288.

Onions.
« Last Edit: April 23, 2011, 03:18:04 pm by Onions » Logged

My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) smiley-grin

field road, jupiter creek
Offline Offline
Sr. Member
****
Karma: 6
Posts: 354
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just keyed the equation, exactly as it is written and got 2!

That was after I got 2 solving it in my head and then reading the rest of the posts!

AS an aside for all the weird little varmints going on about which base...

In maths if it's a different base other than 10, then there is a little subscript notation of base, ie

1010
0A16
128
10102
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 534
Posts: 26970
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Excel says an operator is missing, I am going with that: unclear formula presented.

Otherwise, it wants to correct it to
=48/2*(9+3), for result of 288.
And microsoft is never wrong ...
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18740
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I just keyed the equation, exactly as it is written and got 2!

Into what?
Logged


field road, jupiter creek
Offline Offline
Sr. Member
****
Karma: 6
Posts: 354
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A Casio fx-100AU calculator.

48÷2(9+3) = 2

obviously it's evaluating the bracket argument first.
QBasic on a PC gave the same answer, so did Apple basic on an Apple II.
FPC (free pascal compiler) under Linux also gave 2.
USCD Pascal on an Apple 2 gave 2.

I didn't try any other flavours yet.

But 2 was the answer I got when I evaluated it in my head initially.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18740
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm most impressed that you have got things like UCSD Pascal on an Apple 2. Sadly my Apple 2 has gone away.

I can confirm that on the following calculators I also got the answer 2:

  • Sharp EL-531WH
  • Casio CFX-9850GB Plus

My Casio fx-115 gave the answer 4.
My TI-nspire CAS gave the answer 288.
My HP 50g gave the answer 288.

Interesting.
Logged


Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17293
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are we done yet.  smiley-sleep
Logged

Pages: 1 ... 3 4 [5] 6 7 8   Go Up
Jump to: