Comparing version 0.2.3 to 0.3.0
@@ -0,1 +1,5 @@ | ||
# 0.3.0 (2014-11-25) | ||
* return NaN when not a number | ||
# 0.2.3 (2014-08-23) | ||
@@ -2,0 +6,0 @@ |
17
num.js
@@ -17,2 +17,3 @@ var int = require('int'); | ||
num = num || 0; | ||
// convert to a string | ||
@@ -37,4 +38,5 @@ num = '' + num; | ||
this._int = int(num); | ||
this._precision = prec || precision; | ||
self._int = int(num); | ||
self._precision = prec || precision; | ||
self._nan = self._int._nan; | ||
} | ||
@@ -44,7 +46,12 @@ | ||
Num.prototype.toString = function() { | ||
var self = this; | ||
var num_str = this._int.toString(); | ||
if (self._nan) { | ||
return NaN; | ||
} | ||
var num_str = self._int.toString(); | ||
// 0 precision, just return the int | ||
if (this._precision <= 0) { | ||
if (self._precision <= 0) { | ||
return num_str; | ||
@@ -62,3 +69,3 @@ } | ||
// find index where to add the decimal point | ||
var idx = num_str.length - this._precision; | ||
var idx = num_str.length - self._precision; | ||
@@ -65,0 +72,0 @@ // insert the proper number of 0s after the . |
@@ -5,3 +5,3 @@ { | ||
"description": "arbitrary precision integer and decimal library in javascript", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"repository": { | ||
@@ -20,3 +20,3 @@ "type": "git", | ||
"dependencies": { | ||
"int": "0.1.2" | ||
"int": "0.2.0" | ||
}, | ||
@@ -23,0 +23,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16630
398