Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

278
Views
Why JavaScript cannot properly calculate 9 ** 1/2? The output is 4.5 instead of 3

console.log(Math.pow(9, 1 / 2) === 9 ** 1 / 2) // false

console.log(9 ** 1 / 2) // 4.5

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It's because of operator precedence. ** has a higher precedence than / in the same way that * has higher precedence thatn +.

You wouldn't expect 3 * 3 + 2 to equal 15 do you?

So similarly your 9**1 / 2 is interpreted as (9**1) / 2. If you mean to raise 9 to the power of 0.5 you need to clarify it as:

9 ** (1/2)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!