Precedence of operators - which is correct?
2 views (last 30 days)
Show older comments
I am a beginner and would appreciate your help with this.
I need to code
Which of these 2 MATLAB codes would give me the correct answer?
1) a=24.4*10^-9
2) a=24.4*(10^-9)
I think the operators * and ^ fall under different precedence levels, so I am confused as to which operator would be applied first if I used the 1st line of code.
Thanks
0 Comments
Accepted Answer
Image Analyst
on 9 Dec 2018
Edited: Image Analyst
on 9 Dec 2018
The raising to a power happens first. The multiplication happens second.
The two equations should give the same value - try it.
It is NOT a=(24.4*10) ^ (-9)
You could also do
a=24.4e-9
and get the same number. The 10^ can be replaced by E or e.
0 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!