Nodejs Number Calculate sqrt()

Here you can find the source of sqrt()

Method Source Code

Number.prototype.sqrt = function() {
  return Math.sqrt(this);
};

Related

  1. sigFig(precision)
    'use strict'
    Number.prototype.sigFig = function(precision){
        if( !precision ) precision = 2;
        var d = Math.pow(10, precision);
        return ( parseInt( this.valueOf() * d) / d ).toFixed(precision);
    };
    
  2. simEq(number, digits)
    DEFAULT_DIGIT = 5;
    Number.prototype.simEq = function(number, digits) {
      digits = digits == undefined ? DEFAULT_DIGIT : digits;
      var n1 = this.toFixed(digits);
      var n2 = number.toFixed(digits);
      if (n1 == -0)
        n1 = 0;
      if (n2 == -0)
        n2 = 0;
    ...
    
  3. sin()
    Number.prototype.sin = function() {
        return Math.sin(this);
    
  4. smallerThan(num)
    Number.prototype.smallerThan = function(num) {
        return this < num;
    
  5. snap(resolution)
    Number.prototype.snap = function(resolution) {
      return Math.floor(this / resolution) * resolution;
    };
    
  6. square()
    var expect = chai.expect;
    Number.prototype.square = function () {
        "use strict";
        return this * this;
    };
    
  7. square()
    Number.prototype.square = function() {
      return this * this;
    };
    
  8. step(to, add_remove_step)
    Number.prototype.step = function (to, add_remove_step) {
      var from = this.valueOf();
      var ch = add_remove_step.match(/[\+,\-]/g)[0];
      var i = from;
      var arr = [];
      if (ch === '+') {
        while (i <= to) {
          arr.push(i);
          i = i + parseInt(add_remove_step);
    ...
    
  9. subNum(n)
    Number.prototype.subNum = function(n){
      var f_x = parseFloat(this);
      if (isNaN(f_x)){
        return false;
      f_x = Math.floor(f_x*Math.pow(10,n)+0.0001)/Math.pow(10,n);
      var s_x = f_x.toString();
      var pos_decimal = s_x.indexOf('.');
      if (pos_decimal < 0){
    ...