-2

I would like to know why there is always some difference in value, when I perform the below calculations.

var amt=1000;
var cr= 3.02;
var net = (cr/100)*amt;
console.log(net); //shows 29.02 instead of 30.02
Heretic Monkey
  • 11,078
  • 7
  • 55
  • 112
Senthil
  • 861
  • 1
  • 4
  • 18

1 Answers1

1

You can do * before /.

var amt = 1000;
var cr = 3.02;
var net = cr * amt / 100;
console.log(net);
Julian Lin
  • 1,311
  • 5
  • 17