Nodejs Number Calculate getDecimalgetDecimal()

Here you can find the source of getDecimalgetDecimal()

Method Source Code

Number.prototype.getDecimal = function getDecimal() {
    return parseInt(this, 10);
};

Related

  1. 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);
    ...
    
  2. floatMethod()
    Number.prototype.floatMethod = function() {
        return parseFloat(this).toFixed(2);
    };
    function convert_float() {
        var n = 60.00;
       console.log(n.floatMethod());
    convert_float(n);
    
  3. frac()
    Number.prototype.frac = function() {
      return this - Math.floor(this);
    };
    
  4. fuzzyEqual(otherNumber)
    Number.prototype.fuzzyEqual = function(otherNumber)
        return Math.abs(this - otherNumber) <= 0.00001;
    
  5. gcd(b)
    Number.prototype.gcd = function(b) {
      return (b == 0) ? this : this.gcd(this % b);
    
  6. 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";
    };
    ...
    
  7. getHashCode()
    Number.prototype.getHashCode = function () {
        var x = this;
        x = ((x >> 16) ^ x) * 0x45d9f3b;
        x = ((x >> 16) ^ x) * 0x45d9f3b;
        x = ((x >> 16) ^ x);
        return x;
    };
    
  8. getHisByMs()
    Number.prototype.getHisByMs=function(){
        var ms=this;
        var date=new Date(ms);
        var his=[];
        his.push(Number(date.getHours()).addZero());
        his.push(Number(date.getMinutes()).addZero());
        his.push(Number(date.getSeconds()).addZero());
        return his;
    
  9. getPrecisiongetPrecision(length)
    Number.prototype.getPrecision = function getPrecision(length) {
        var value = parseFloat(this);
        if (Number.isFloat(value)) {
            return value.toString().split(".")[1].length;
        return 0;
    };