Nodejs Number Calculate fuzzyEqual(otherNumber)

Here you can find the source of fuzzyEqual(otherNumber)

Method Source Code

Number.prototype.fuzzyEqual = function(otherNumber)
{
    return Math.abs(this - otherNumber) <= 0.00001;
}

Related

  1. fix(n)
    Number.prototype.fix = function (n) {
        var val = String(this);
        n = Math.abs(n);
        val = val.split('.');
        val[1] = val[1] || '';
        var m = val[1].length;
        if (m < n) {
            m = n - m;
            while (m > 0) {
    ...
    
  2. fizz()
    Number.prototype.fizz = function() {
        return this % 3 === 0 ? "fizz" : "";
    };
    Number.prototype.buzz = function() {
        return this % 5 === 0 ? "buzz" : "";
    };
    for (var i = 1; i <= 15; i++) {
        var candidate = Number(i).fizz() + Number(i).buzz();
        console.log(candidate ? candidate : i);
    ...
    
  3. float()
    var num = 5;
    Number.prototype.float = function(){ 
          return this.toFixed(2);
    Number.prototype.int = function(){ 
          return parseInt(this) ;
    console.log(num.float());
    console.log(num);
    ...
    
  4. floatMethod()
    Number.prototype.floatMethod = function() {
        return parseFloat(this).toFixed(2);
    };
    function convert_float() {
        var n = 60.00;
       console.log(n.floatMethod());
    convert_float(n);
    
  5. frac()
    Number.prototype.frac = function() {
      return this - Math.floor(this);
    };
    
  6. gcd(b)
    Number.prototype.gcd = function(b) {
      return (b == 0) ? this : this.gcd(this % b);
    
  7. getDecimalgetDecimal()
    Number.prototype.getDecimal = function getDecimal() {
        return parseInt(this, 10);
    };
    
  8. getDisplayText(number)
    Number.getDisplayText = function(number) {
        if (number < 1000) {
            return number;
        if (number < 1000000) {
            return (number / 1000).toFixed(1) * 1 + "k";
        return (number / 1000000).toFixed(1) * 1 + "m";
    };
    ...
    
  9. getHashCode()
    Number.prototype.getHashCode = function () {
        var x = this;
        x = ((x >> 16) ^ x) * 0x45d9f3b;
        x = ((x >> 16) ^ x) * 0x45d9f3b;
        x = ((x >> 16) ^ x);
        return x;
    };