Monday, June 11, 2018

JavaScript - Floating Point Division - Miscalculation - toFixed Function

Below is a demonstration of usage of toFixed function used for addressing Miscalculation caused due to division of floating point division in JavaScript

var a = 3.3;
var b = 2.2;

a /=b;

console.log((a).toFixed(2));

Try it out at : http://jsbin.com

No comments:

Post a Comment