diff options
| -rwxr-xr-x | history.txt | 1 | ||||
| -rw-r--r-- | threads.js | 36 |
2 files changed, 20 insertions, 17 deletions
diff --git a/history.txt b/history.txt index 1618601..fe347fa 100755 --- a/history.txt +++ b/history.txt @@ -2011,3 +2011,4 @@ ______ ------ * Cloud: fixed #125 (encode email address when signing up), thanks, Nathan! * Threads: fixed #207 (stricter comparison of strings vs. numbers). Some edge cases remain, such as empty string equals zero and disregarding trailing / leading blanks. These are intentional. Please don’t nitpick and spare me the fundamentalism :-) +* Threads: fixed #245 (consistently auto-convert empty strings to zeroes) @@ -98,7 +98,7 @@ function snapEquals(a, b) { } return false; } - var x = +a; + var x = +a, y = +b; if (isNaN(x) || isNaN(y)) { x = a; @@ -1842,30 +1842,30 @@ Process.prototype.reportTypeOf = function (thing) { // Process math primtives Process.prototype.reportSum = function (a, b) { - return parseFloat(a) + parseFloat(b); + return +a + (+b); }; Process.prototype.reportDifference = function (a, b) { - return parseFloat(a) - parseFloat(b); + return +a - +b; }; Process.prototype.reportProduct = function (a, b) { - return parseFloat(a) * parseFloat(b); + return +a * +b; }; Process.prototype.reportQuotient = function (a, b) { - return parseFloat(a) / parseFloat(b); + return +a / +b; }; Process.prototype.reportModulus = function (a, b) { - var x = parseFloat(a), - y = parseFloat(b); + var x = +a, + y = +b; return ((x % y) + y) % y; }; Process.prototype.reportRandom = function (min, max) { - var floor = parseFloat(min), - ceil = parseFloat(max); + var floor = +min, + ceil = +max; if ((floor % 1 !== 0) || (ceil % 1 !== 0)) { return Math.random() * (ceil - floor) + floor; } @@ -1873,8 +1873,8 @@ Process.prototype.reportRandom = function (min, max) { }; Process.prototype.reportLessThan = function (a, b) { - var x = parseFloat(a), - y = parseFloat(b); + var x = +a, + y = +b; if (isNaN(x) || isNaN(y)) { x = a; y = b; @@ -1887,8 +1887,8 @@ Process.prototype.reportNot = function (bool) { }; Process.prototype.reportGreaterThan = function (a, b) { - var x = parseFloat(a), - y = parseFloat(b); + var x = +a, + y = +b; if (isNaN(x) || isNaN(y)) { x = a; y = b; @@ -1942,11 +1942,11 @@ Process.prototype.reportFalse = function () { }; Process.prototype.reportRound = function (n) { - return Math.round(parseFloat(n)); + return Math.round(+n); }; Process.prototype.reportMonadic = function (fname, n) { - var x = parseFloat(n), + var x = +n, result = 0; switch (this.inputOption(fname)) { @@ -1990,6 +1990,7 @@ Process.prototype.reportMonadic = function (fname, n) { result = 0; break; default: + nop(); } return result; }; @@ -2021,6 +2022,7 @@ Process.prototype.reportTextFunction = function (fname, string) { result = hex_sha512(x); break; default: + nop(); } return result; }; @@ -2041,7 +2043,7 @@ Process.prototype.reportJoinWords = function (aList) { // Process string ops Process.prototype.reportLetter = function (idx, string) { - var i = parseFloat(idx || 0), + var i = +(idx || 0), str = (string || '').toString(); return str[i - 1] || ''; }; @@ -2057,7 +2059,7 @@ Process.prototype.reportUnicode = function (string) { }; Process.prototype.reportUnicodeAsLetter = function (num) { - var code = parseFloat(num || 0); + var code = +(num || 0); return String.fromCharCode(code); }; |
