Precedence of operators - which is correct?

I am a beginner and would appreciate your help with this.
I need to code a1.JPG
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

 Accepted Answer

Image Analyst
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.

More Answers (0)

Categories

Find more on Get Started with MATLAB 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!