0

HTML

$(function() {
  $("#num1, #num2").on("keydown keyup", sum);

  function sum() {
    $("#subt").val(
      Number($("#num1").val()) -
      Number($("#num2").val())
    );
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="number" id="num1">
<input type="number" id="num2">
<input type="number" id="subt" readonly="">
Dave Newton
  • 158,873
  • 26
  • 254
  • 302
RadRafs
  • 1
  • 1
  • 3
    See [Is floating point mathbroken](https://stackoverflow.com/questions/588004/is-floating-point-math-broken/588019#588019), which this duplicates. For exhaustive details see [What Every Computer Scientist Should Know About Floating Point Arithmetic](https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html). – Dave Newton Apr 13 '22 at 15:22
  • `` seems to be missing the ID it needs – j08691 Apr 13 '22 at 15:24

0 Answers0