0 registered members (),
167
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
Forums70
Topics113,778
Posts1,340,834
Members1,715
|
Most Online2,346 Apr 14th, 2025
|
|
|
A quick maths question...
#1372754
30/08/2012 12:03
30/08/2012 12:03
|
Joined: Sep 2009
Posts: 5,112 ation
szkom
OP
Club member 2000
|
OP
Club member 2000
Forum is my life
Joined: Sep 2009
Posts: 5,112
ation
|
3+3x4= So, go on then what do people think is the answer? Show your working for extra credit 
|
|
|
Re: A quick maths question...
[Re: szkom]
#1372757
30/08/2012 12:07
30/08/2012 12:07
|
Turbo_Verde
Unregistered
|
Turbo_Verde
Unregistered
|
BODMAS!
Thus the answer is 15.
Just look at it like 3+(3x4) rather than (3+3)x4.
(Hope I'm right now )
|
|
|
Re: A quick maths question...
[Re: szkom]
#1372766
30/08/2012 12:27
30/08/2012 12:27
|
Turbo_Verde
Unregistered
|
Turbo_Verde
Unregistered
|
Firstly I admit what ever Barnacle is going on about has gone miles over my head.
Secondly it is not 'more correct' to add the brackets. It may make it easier to understand for many (me included as don't have to think about it then) but it is just as accurate with or without the brackets.
|
|
|
Re: A quick maths question...
[Re: barnacle]
#1372776
30/08/2012 13:14
30/08/2012 13:14
|
Joined: Dec 2005
Posts: 12,546 Northumberland
AndrewR
I AM a Coop
|
I AM a Coop
Joined: Dec 2005
Posts: 12,546
Northumberland
|
Addition is subordinate to multiplication.
But you haven't stated the base: Well if we're going to be fancy about it neither has the modulo been stated, so: Mod 5 (lowest possible) = 0 Mod 6 = 3 Mod 7 = 1 Mod 8 = 7 Mod 9 = 6 Mod 10 = 5 Mod 11 = 4 Mod 12 = 3 Mod 13 = 2 Mod 14 = 1 Mod 15 = 0 Mod 16 (and higher) = 15 Combining the moduli and base combinations is left as an exercise for the reader 
Dear monos, a secret truth.
|
|
|
Re: A quick maths question...
[Re: AndrewR]
#1372781
30/08/2012 13:31
30/08/2012 13:31
|
Joined: Dec 2005
Posts: 33,785 Berlin
barnacle
Club Member 18 - ex-Minister without Portfolio
|
Club Member 18 - ex-Minister without Portfolio
Forum Demigod
Joined: Dec 2005
Posts: 33,785
Berlin
|
neither has the modulo been stated, so: Modulus is the singular of moduli; modulo is the name of the operation...
|
|
|
Re: A quick maths question...
[Re: szkom]
#1372783
30/08/2012 13:36
30/08/2012 13:36
|
Joined: Dec 2005
Posts: 6,731 Surrey
Emjay
Forum is my life
|
Forum is my life
Joined: Dec 2005
Posts: 6,731
Surrey
|
Well if we're worried about sloppiness, those are parentheses. Parentheses are one type of bracket, but not all brackets are parentheses.
Does our law condemn a man without first hearing him to find out what he has been doing? (John 7:51)
|
|
|
Re: A quick maths question...
[Re: szkom]
#1372785
30/08/2012 13:38
30/08/2012 13:38
|
Joined: Dec 2005
Posts: 6,731 Surrey
Emjay
Forum is my life
|
Forum is my life
Joined: Dec 2005
Posts: 6,731
Surrey
|
3+3x4=
So, go on then what do people think is the answer? What do you want it to be? [/lawyer mode]
Does our law condemn a man without first hearing him to find out what he has been doing? (John 7:51)
|
|
|
Re: A quick maths question...
[Re: szkom]
#1372790
30/08/2012 13:47
30/08/2012 13:47
|
Joined: Dec 2005
Posts: 33,785 Berlin
barnacle
Club Member 18 - ex-Minister without Portfolio
|
Club Member 18 - ex-Minister without Portfolio
Forum Demigod
Joined: Dec 2005
Posts: 33,785
Berlin
|
Here's what I've just had to write (and debug) in PIC machine code this morning:
static uint32 random
random ^= random << 1;
random ^= random >> 3;
random ^= random << 10;
Pseudo random number generator with good properties and a (2^32)-1 repeat cycle. I had need of some random!
|
|
|
Re: A quick maths question...
[Re: szkom]
#1372791
30/08/2012 13:49
30/08/2012 13:49
|
Joined: Dec 2005
Posts: 12,546 Northumberland
AndrewR
I AM a Coop
|
I AM a Coop
Joined: Dec 2005
Posts: 12,546
Northumberland
|
My morning's coding is still a work-in-progress: Sub MakeSummary()
Const sSUMMARY_TAG As String = "Summary"
Const sQUESTION_DELIMITER As String = " "
Const sPRODUCT_RANGE As String = "A8"
Const sPRODUCT_DELIMITER As String = "..."
Const sSTART_RANGE As String = "B10"
Dim wshLoop As Worksheet
Dim sQuestion As String
Dim asSheetName() As String
Dim asProduct() As String
Dim bFirstPass As Boolean
Dim rngThisQ As Range
Dim sThisProduct As String
Dim bSheetMatched As Boolean
Dim lSheetLoop As Long
Dim wshSource As Worksheet
Dim sStatement As String
Dim rngFindStat As Range
bFirstPass = True
For Each wshLoop In ActiveWorkbook.Sheets
If bFirstPass Then
ReDim asSheetName(1 To 1)
ReDim asProduct(1 To 1)
bFirstPass = False
Else
ReDim Preserve asSheetName(1 To UBound(asSheetName) + 1)
ReDim Preserve asProduct(1 To UBound(asProduct) + 1)
End If
asSheetName(UBound(asSheetName)) = wshLoop.Name
If InStr(wshLoop.Range(sPRODUCT_RANGE).Value, sPRODUCT_DELIMITER) = 0 Then
asProduct(UBound(asProduct)) = "NULL"
Else
asProduct(UBound(asProduct)) = Mid(wshLoop.Range(sPRODUCT_RANGE), InStr(wshLoop.Range(sPRODUCT_RANGE), sPRODUCT_DELIMITER) + Len(sPRODUCT_DELIMITER))
'MsgBox asProduct(UBound(asProduct))
End If
If InStr(wshLoop.Name, sSUMMARY_TAG) > 0 Then
sQuestion = Left(wshLoop.Name, InStr(wshLoop.Name, sQUESTION_DELIMITER))
If sQuestion <> "Q11" Then
Set rngThisQ = wshLoop.Range(sSTART_RANGE)
While rngThisQ.Row <= wshLoop.Cells(wshLoop.Rows.Count, rngThisQ.Column).End(xlUp).Row
lSheetLoop = 1
bSheetMatched = False
While lSheetLoop <= UBound(asSheetName) And Not (bSheetMatched)
If Left(asSheetName(lSheetLoop), InStr(wshLoop.Name, " ") - 1) = Left(wshLoop.Name, InStr(wshLoop.Name, " ") - 1) And InStr(asProduct(lSheetLoop), rngThisQ.Value) > 0 Then
bSheetMatched = True
Else
lSheetLoop = lSheetLoop + 1
End If
Wend
If Not bSheetMatched Then
MsgBox rngThisQ.Value & " could not be found"
Else
'MsgBox ActiveWorkbook.Sheets(lSheetLoop).Name
Set wshSource = ActiveWorkbook.Sheets(lSheetLoop)
End If
Set rngThisQ = rngThisQ.End(xlDown)
Wend
End If
Next wshLoop
End Sub
Dear monos, a secret truth.
|
|
|
Re: A quick maths question...
[Re: Emjay]
#1372795
30/08/2012 13:54
30/08/2012 13:54
|
Joined: Jun 2006
Posts: 6,144 Southampton, Hants
Roadking
Club member 1809
|
Club member 1809
Forum is my life
Joined: Jun 2006
Posts: 6,144
Southampton, Hants
|
3+3x4=
So, go on then what do people think is the answer? What do you want it to be? [/lawyer mode] So a hefty bill incoming for that written response 
"RK's way seems the most sensible to me". ali_hire 16 Dec 2010
|
|
|
Re: A quick maths question...
[Re: ]
#1372799
30/08/2012 14:26
30/08/2012 14:26
|
TimR
Unregistered
|
TimR
Unregistered
|
BODMAS!
Thus the answer is 15.
Just look at it like 3+(3x4) rather than (3+3)x4.
(Hope I'm right now ) I think I always got told BO MDAS but it was 25 years ago. Can't believe you didn't get the 'what would you like it to be' question in first. Aren't you an accountant?
|
|
|
Re: A quick maths question...
[Re: ]
#1372800
30/08/2012 14:33
30/08/2012 14:33
|
Turbo_Verde
Unregistered
|
Turbo_Verde
Unregistered
|
BODMAS!
Thus the answer is 15.
Just look at it like 3+(3x4) rather than (3+3)x4.
(Hope I'm right now ) I think I always got told BO MDAS but it was 25 years ago. Can't believe you didn't get the 'what would you like it to be' question in first. Aren't you an accountant? HAHA, good point. If you paid me I can make 3+3x4 equal anything you want and justify it to the tax man 
As for whether it is BODMAS or BOMDAS, it doesn't matter. Divison and multiplication have the same authority, as do addition and subtraction. So really it looks like this:
BO/D\/A\ ---\M/\S/
|
|
|
Re: A quick maths question...
[Re: barnacle]
#1372821
30/08/2012 16:00
30/08/2012 16:00
|
jonnybgt1759
Unregistered
|
jonnybgt1759
Unregistered
|
Um, no they don't... formally, they are at the same level of precedence but must be evaluated left to right. Sometimes this makes a difference - I can't think of a real world example right now, but it's significant in computer code where word length or floating point precision may affect intermediate results.
e.g. Pi ~= 355/113, so you can calculate the volume of a sphere radius 2 in integers as either:
v = 4/3 pi r^3 = (4 * 355 * 2 * 2 * 2)/(3 * 113) = 33
or (4/3) * (355/113) * (2 * 2 * 2) = 1 * 3 * 8 = 24
The first is the more correct.
you should work for nasa! lol whats your IQ?
|
|
|
Re: A quick maths question...
[Re: szkom]
#1372825
30/08/2012 16:11
30/08/2012 16:11
|
Joined: Dec 2005
Posts: 12,546 Northumberland
AndrewR
I AM a Coop
|
I AM a Coop
Joined: Dec 2005
Posts: 12,546
Northumberland
|
Is there really a computer language which arbitrarily assigns integer values to intermediate calculations? As I had a VBA editor open this line of code: Debug.Print Int((4 / 3) * (355 / 113) * (2 * 2 * 2)) Returns 33, as any reasonable person would expect.
Dear monos, a secret truth.
|
|
|
Re: A quick maths question...
[Re: AndrewR]
#1372827
30/08/2012 16:25
30/08/2012 16:25
|
jonnybgt1759
Unregistered
|
jonnybgt1759
Unregistered
|
Is there really a computer language which arbitrarily assigns integer values to intermediate calculations? As I had a VBA editor open this line of code: Debug.Print Int((4 / 3) * (355 / 113) * (2 * 2 * 2)) Returns 33, as any reasonable person would expect. If the answer is not already yes. Then a protocal could be created for the question.
|
|
|
Re: A quick maths question...
[Re: szkom]
#1372844
30/08/2012 17:06
30/08/2012 17:06
|
Joined: Dec 2005
Posts: 33,785 Berlin
barnacle
Club Member 18 - ex-Minister without Portfolio
|
Club Member 18 - ex-Minister without Portfolio
Forum Demigod
Joined: Dec 2005
Posts: 33,785
Berlin
|
VBA uses floating point numbers by default.
C, C++, Java, C#, Mono, Python, and many others from the Algol-derived school use integers by default. (Machine code uses bytes by default, unless you explicitly use a floating point unit.)
Not only are integers the default, but you can have integers of different length depending on target processor... 16 bits is the usual minimum for C but they can be up to 64 bits.
When an operation between to variables of different size/type is performed, the protocol requires that the smaller be extended to the larger though this can be over-ridden by casting in most languages - so multiplying an integer by a floating point will produce a floating point result - but does *not* require that intermediate products are increased in size. For example, multiplying two sixteen-bit numbers produces a 32-bit result. Since that result has to fit in a sixteen bit target, if the top sixteen bits are anything other than zero, there's an overflow and the answer will not be what you thought. This is not an issue as long as you are aware of what's going on...
Johnny - according to a Mensa test I did thirty-odd years ago to settle a bet, it's high enough to be in the top 0.003%. It's probably worn off a bit since then...
|
|
|
Re: A quick maths question...
[Re: barnacle]
#1372852
30/08/2012 17:22
30/08/2012 17:22
|
jonnybgt1759
Unregistered
|
jonnybgt1759
Unregistered
|
VBA uses floating point numbers by default.
C, C++, Java, C#, Mono, Python, and many others from the Algol-derived school use integers by default. (Machine code uses bytes by default, unless you explicitly use a floating point unit.)
Not only are integers the default, but you can have integers of different length depending on target processor... 16 bits is the usual minimum for C but they can be up to 64 bits.
When an operation between to variables of different size/type is performed, the protocol requires that the smaller be extended to the larger though this can be over-ridden by casting in most languages - so multiplying an integer by a floating point will produce a floating point result - but does *not* require that intermediate products are increased in size. For example, multiplying two sixteen-bit numbers produces a 32-bit result. Since that result has to fit in a sixteen bit target, if the top sixteen bits are anything other than zero, there's an overflow and the answer will not be what you thought. This is not an issue as long as you are aware of what's going on...
Johnny - according to a Mensa test I did thirty-odd years ago to settle a bet, it's high enough to be in the top 0.003%. It's probably worn off a bit since then... Thats very good does your family share this or are you the brainy one of the bunch? A little off topic a question for you do you believe computers will always talk binary beyond ipv6?
|
|
|
Re: A quick maths question...
[Re: ]
#1372854
30/08/2012 17:24
30/08/2012 17:24
|
Joined: Dec 2005
Posts: 6,731 Surrey
Emjay
Forum is my life
|
Forum is my life
Joined: Dec 2005
Posts: 6,731
Surrey
|
Whereas I look at that and it reminds me of Darth Vader's little spaceship, so suspect I am with the other 99.997% who are not barnacle
Does our law condemn a man without first hearing him to find out what he has been doing? (John 7:51)
|
|
|
Re: A quick maths question...
[Re: barnacle]
#1372860
30/08/2012 17:42
30/08/2012 17:42
|
Joined: Dec 2005
Posts: 12,546 Northumberland
AndrewR
I AM a Coop
|
I AM a Coop
Joined: Dec 2005
Posts: 12,546
Northumberland
|
C, C++, Java, C#, Mono, Python, and many others from the Algol-derived school use integers by default. (Machine code uses bytes by default, unless you explicitly use a floating point unit.) So if I have: The value of x will depend on whether I've declared x as a FP variable or an integer and could produce a vastly different result to: Is that right? If so I'm glad I have no truck with any of the languages you've listed 
Dear monos, a secret truth.
|
|
|
Re: A quick maths question...
[Re: szkom]
#1372867
30/08/2012 17:58
30/08/2012 17:58
|
Joined: Dec 2005
Posts: 33,785 Berlin
barnacle
Club Member 18 - ex-Minister without Portfolio
|
Club Member 18 - ex-Minister without Portfolio
Forum Demigod
Joined: Dec 2005
Posts: 33,785
Berlin
|
The result will be x=0.0 in the first case and x=10.0 in the second; the numbers themselves are integers, so the integer divide of 2 by 3 is zero. The type of the answer means only that the result is promoted to that type. To use floats directly, you need to either explicitly cast them: x = (float)15 * (float)2/(float)3 or explicitly use something the compiler understands as float: [code] x = 15.0 * 2.0/3.0 [code]
|
|
|
|