August 5, 201115 yr I finding it difficult to understand a calculation and the tutorial says: 'notice the maths seems worng - there are no fractions, only whole numbers. Find out why by researching what a "floating point" number is.' Here is the calculation: 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 =7 and if I write: 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0 =6.75 I have tried to get these answers but I cannot seem to figure it out - any ideas? Edited August 5, 201115 yr by jheg
August 5, 201115 yr is there any implied precision in the result field therefore 6.75 is rounded up to be 7?
August 5, 201115 yr I finding it difficult to understand a calculation and the tutorial says: 'notice the maths seems worng - there are no fractions, only whole numbers. Find out why by researching what a "floating point" number is.' Here is the calculation: 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 =7 and if I write: 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0 =6.75 I have tried to get these answers but I cannot seem to figure it out - any ideas? Hi there! This is a basic lesson in Algebra which is also my favorite subject. Since this algebra, we have to follow the rules to get the correct answer. In this case, you need to follow EMDAS Rule of Arithmetic Operation (Exponentiation, Multiplication, Division, Addition and Subtraction). Meaning, Division comes first before addition and subtraction comes last. The problem 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 = 7 can be computed by this manner: (3 + 2 + 1} - 5 + [4 %( (2 - 1) / 4)] + 6 = 7... Now your problem is solved. Edited August 5, 201115 yr by Afternoon Sun
August 5, 201115 yr Author Thanks zed I guessed that was what the difference was but I am struggling to understand the equation here and how is calculated. For example: 3.0 + 2.0 (=5) + 1.0 (=6)- 5.0 (=1) + 4.0 (=5) % 2.0 (?) - 1.0 / 4.0 + 6.0 I'm trying to understand how this calculation is calculated...
August 5, 201115 yr Author Hi there! This is a basic lesson in Algebra which is also my favorite subject. Since this algebra, we have to follow the rules to get the correct answer. In this case, you need to follow EMDAS Rule of Arithmetic Operation (Exponentiation, Multiplication, Division, Addition and Subtraction). Meaning, Division comes first before addition and subtraction comes last. The problem 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 = 7 can be computed by this manner: (3 + 2 + 1} - 5 + [4 %( (2 - 1) / 4)] + 6 = 7... Now your problem is solved. Thanks AS thats exactly what I was after now I just need to digest it - thanks and +1
August 5, 201115 yr Author (3 + 2 + 1} - 5 + [4 %( (2 - 1) / 4)] + 6 = 7... Can you explain this a bit more.. (3 + 2 + 1} (6) - 5 (1) + [4 %( (2 - 1) / 4)] This section is confusing me!! + 6 = 7 [4% ((2-1)/4)] - I'm sure its not but to me I'm reading this as 1 divided by 4 times 4% ? Edited August 5, 201115 yr by jheg
August 5, 201115 yr Can you explain this a bit more.. (3 + 2 + 1} (6) - 5 (1) + [4 %( (2 - 1) / 4)] This section is confusing me!! + 6 = 7 [4% ((2-1)/4)] - I'm sure its not but to me I'm reading this as 1 divided by 4 times 4% ? [4 %( (2 - 1) / 4)] This section follows the process: a. 2-1 = 1 b. 1/4 = .25 c. 4%.25 = 0 therefore, you have: 6 - 5 + 0 + 6 = 7... By the way the sign % doesn't mean 'percent' but 'modulus'. It is the remainder after division. Edited August 5, 201115 yr by Afternoon Sun
August 5, 201115 yr Author [4 %( (2 - 1) / 4)] This section follows the process: a. 2-1 = 1 b. 1/4 = .25 c. 4%.25 = 0 therefore, you have: 6 - 5 + 0 + 6 = 7... By the way the sign % doesn't mean 'percent' but 'modulus'. It is the remainder after division. a and b fine I understand but what is the 4 doing to the % and what is that doing with .25 - sorry man I'm struggling to get it
August 8, 201115 yr a and b fine I understand but what is the 4 doing to the % and what is that doing with .25 - sorry man I'm struggling to get it I think you need to do a bit of reading on Mathematical Operators for programming. It's already been pointed out that the '%' is not a percent operator, rather a modulus, meaning it returns the remainder of the equation. For example, 5%2 would return an answer of 1 which is the remainder and NOT 2.5 which is the precise calculation.
August 8, 201115 yr Here is the calculation: 3 + 2 + 1=6 6- 5=1 1 + 4=5 5 % 2=1 1 - 1=0 0 / 4=0 0 + 6=6 so the correct answer is 6 not 6.75 nor 7 Because % shows the remainder not division or anything else and if I write: 3.0 + 2.0 + 1.0 = 6.0 6.0- 5.0= 1.0 1.0 + 4.0=5.0 5.0 % 2.0 = 1.0 1.0- 1.0 = 0 0/ 4.0 = 0 0 + 6.0 =6.0 so the correct answer in both the case is =6.00
Create an account or sign in to comment