summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Ball <cycomachead@gmail.com>2015-06-15 17:19:25 -0700
committerMichael Ball <cycomachead@gmail.com>2015-06-15 17:19:25 -0700
commite21a872b0dcbca2e7ea8311d9b54f709876d1848 (patch)
tree695d64b8c3134188f2cb32bcd1c2401a555b27c9
parent3885ced35aee903f74d48c293bc3f0665a38dba5 (diff)
downloadsnap-e21a872b0dcbca2e7ea8311d9b54f709876d1848.tar.gz
snap-e21a872b0dcbca2e7ea8311d9b54f709876d1848.zip
Implement log10 and 10^x math functions
-rw-r--r--blocks.js6
-rw-r--r--threads.js6
2 files changed, 6 insertions, 6 deletions
diff --git a/blocks.js b/blocks.js
index 67324ca..1ef322c 100644
--- a/blocks.js
+++ b/blocks.js
@@ -1111,9 +1111,9 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
acos : ['acos'],
atan : ['atan'],
ln : ['ln'],
- // log : 'log',
- 'e^' : ['e^']
- // '10^' : '10^'
+ log : ['log'],
+ 'e^' : ['e^'],
+ '10^' : ['10^']
},
true
);
diff --git a/threads.js b/threads.js
index 165ad0e..61b5722 100644
--- a/threads.js
+++ b/threads.js
@@ -2122,14 +2122,14 @@ Process.prototype.reportMonadic = function (fname, n) {
case 'ln':
result = Math.log(x);
break;
- case 'log':
- result = 0;
+ case 'log': // base 10
+ result = Math.log(x) / Math.LN10;
break;
case 'e^':
result = Math.exp(x);
break;
case '10^':
- result = 0;
+ result = Math.pow(10, x);
break;
default:
nop();