+ 2
Question
Hello everyone, I'm a new learner here, I want to ask some question, I still don't understand very well about this math calculation. Can anyone explain this? Math.abs(Math.min(-6, 3)); Math.abs(-6,3); // 6,3 so the min = 3 Math.min(-6,3); // -6,3 so the min = -6 Math.abs(Math.min(-6, 3)); // why this equal 6 ? not 3 ?
5 odpowiedzi
+ 7
Well, the reason it doesn't equal 3 is because you just have the order of the math wrong. What the program does is evaluate any expression within the inner most parentheses first, then moves its way outwards.
In this case, the program first evaluates what the lowest value is out of the two options (-6 and 3), which returns -6. From there, it finds the absolute value of the result of the previous calculation, resulting in 6.
Hope this helped!
+ 16
first find min. of -6,3 & then take the absolute value of the result
//Math.abs (-6); = 6
+ 1
Thank you very much, now I can understand it clearly.
0
because it -6 not 6
0
First it checked minimum. example ,
min(7,-9),so min=-9
secondly checked absolute . example,
abs(-9).
this is not the answer. it will be 9. because abs(-9)=[-9]=9.