Number.js

できてないから

by ethertank

JavaScript

(function(N, global) {
    // ECMAScript Specification Types
    //   ReturnIfAbrupt
 
    // Abstract Operations
    //   ToNumber ToInteger ToInt32 ToUint32 ToInt16 ToUint16 ToInt8 ToUint8 ToUint8Clamp
 
    /*
    function ToNumber() { return }
    function ToInteger() { return }
    function Type(v) { return }
    */
 
    // Number.prototype
    //   Number.prototype.clz ()
    //   Number.prototype.constructor
    //   Number.prototype.toExponential ()
    //   Number.prototype.toFixed ()
    //   Number.prototype.toLocaleString()
    //   Number.prototype.toPrecision ()
    //   Number.prototype.toString ( [ radix ] )
    //   Number.prototype.valueOf ( )
 
    // Number.MAX_VALUE, Number.MIN_VALUE
    // Number.NaN
    // Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY
 
    // [ES6]
    // Number.isFinite(), Number.isNaN()
    // Number.EPSILON
    // Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER
 
    // global.Infinity
    // global.NaN
    // global.isFinite()
    // grobal.isNaN()
 
 
    // 不完全
    // The value of Number.MAX_SAFE_INTEGER is 9007199254740991 (2e53-1)
    // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
    // IE8 の Object.defineProperty は Dom オブジェクトでのみ有効で、動作も異なる
    if(!N.MAX_SAFE_INTEGER) {
        N.MAX_SAFE_INTEGER = 9007199254740991;
        Object.defineProperty && Object.defineProperty(N, "MAX_SAFE_INTEGER", {
            writable : false,
            enumerable : false,
            configurable : false
        });
    }
    
    if(!N.MIN_SAFE_INTEGER) {
        N.MIN_SAFE_INTEGER = -9007199254740991; 
        Object.defineProperty && Object.defineProperty(N, "MIN_SAFE_INTEGER", {
            writable : false,
            enumerable : false,
            configurable : false
        });
    }
 
    // 不完全
    // The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 that is representable as a Number value,
    // which is...