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

108
Views
JavaScript returns false calculation results

I'm having trouble having the correct result. Below is my code

function Funtpcal() {
  var consiz = document.getElementById("consiz").value;
  var cmsn = document.getElementById("cmsn").value;

  var x = document.getElementById("tp_vol").value;
  var y = document.getElementById("tp_op").value;
  var w = document.getElementById("tp_tp").value;

    var z = -(((cmsn-100000)*(y*consiz*x))+(100000*w))/((cmsn+100000)*consiz*x);
    document.getElementById("tp").innerHTML = z.toFixed(3);
}
<input type="number" id="consiz" value="1000">
<input type="number" id="cmsn" value="1">
<input type="number" id="tp_vol" value="11.35">
<input type="number" id="tp_op" value="110">
<input type="number" id="tp_tp" value="100">

<input type="button" onclick="Funtpcal()" value="Calculate">
<span id="tp"></span>

Correct result is 109.989 as if you were to do this

var z = -(((1-100000)*(110*1000*11.35))+(100000*100))/((1+100000)*1000*11.35);

So tell me what is going wrong

about 4 years ago · Juan Pablo Isaza
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!