0

I am facing the issue while round numbers in 2 decimal points using javascript function toFixed

It's working for all the values except some cases

For example : Value is : 3.675 Then it should be 3.68

I have tried it as below

var ans = Number(DiscountValue).toFixed(2);

I have even tried with the following code

var ans = parseFloat(DiscountValue).toFixed(2);

But its returning 3.67

Anyone face this issue before

Plz guide how we can sort this !

Asons
  • 84,923
  • 12
  • 110
  • 165
Kashyap Patel
  • 1,139
  • 1
  • 13
  • 29
  • 1
    First, `toFixed` is a javascript function, not jQuery, second, this might help: http://stackoverflow.com/questions/10808671/javascript-how-to-prevent-tofixed-from-rounding-off-decimal-numbers – Asons Mar 21 '17 at 14:29

1 Answers1

1
Math.round(num * 100) / 100

It will give you the result you are expecting

Pramod_Para
  • 671
  • 3
  • 10