aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js2
-rw-r--r--src/parseTools.js3
-rw-r--r--src/preamble.js12
3 files changed, 14 insertions, 3 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index c9c2a63b..d4cfc07a 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -490,6 +490,8 @@ function JSify(data) {
});
makeFuncLineZyme('mathop', function(item) { with(item) {
dprint('mathop', 'mathop: ' + dump(item));
+ ident = parseNumerical(ident);
+ ident2 = parseNumerical(ident2);
switch (item.op) {
case 'add': return ident + ' + ' + ident2;
case 'sub': return ident + ' - ' + ident2;
diff --git a/src/parseTools.js b/src/parseTools.js
index 456b44f1..f0ac834c 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -335,7 +335,8 @@ function IEEEUnHex(stringy) {
}
}
e -= 1023; // offset
- return (((((a & 0xfffff | 0x100000) * 1.0) / Math.pow(2,52-32)) * Math.pow(2, e)) + (((b * 1.0) / Math.pow(2, 52)) * Math.pow(2, e)) * (neg ? -1 : 1)).toString();
+ var absolute = ((((a & 0xfffff | 0x100000) * 1.0) / Math.pow(2,52-32)) * Math.pow(2, e)) + (((b * 1.0) / Math.pow(2, 52)) * Math.pow(2, e));
+ return (absolute * (neg ? -1 : 1)).toString();
}
function parseNumerical(value, type) {
diff --git a/src/preamble.js b/src/preamble.js
index a2ceaa0c..e458384d 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -136,8 +136,16 @@ function __formatString() {
while (curr != 0) {
curr = HEAP[textIndex];
next = HEAP[textIndex+1];
- if (curr == '%'.charCodeAt(0) && ['d', 'f'].indexOf(String.fromCharCode(next)) != -1) {
- String(arguments[argIndex]).split('').forEach(function(chr) {
+ if (curr == '%'.charCodeAt(0) && ['d', 'f', '.'].indexOf(String.fromCharCode(next)) != -1) {
+ var argText = String(arguments[argIndex]);
+ // Handle very very simply formatting, namely only %.Xf
+ if (HEAP[textIndex+1] == '.'.charCodeAt(0)) {
+ var limit = parseInt(String.fromCharCode(HEAP[textIndex+2]));
+ var dotIndex = argText.indexOf('.');
+ argText = argText.substr(0, dotIndex+1+limit);
+ textIndex += 2;
+ }
+ argText.split('').forEach(function(chr) {
ret.push(chr.charCodeAt(0));
});
argIndex += 1;