Verified Commit df808685 authored by Camil Staps's avatar Camil Staps 🙂

Use toPrecision instead of toLocaleString for wasm version of RtoAC and...

Use toPrecision instead of toLocaleString for wasm version of RtoAC and print_real (performance reasons)
parent 7579f40d
...@@ -567,13 +567,7 @@ class ABCInterpreter { ...@@ -567,13 +567,7 @@ class ABCInterpreter {
me.log("'"+String.fromCharCode(v)+"'"); me.log("'"+String.fromCharCode(v)+"'");
}, },
print_real: function (v) { print_real: function (v) {
me.log(Number(0+v).toLocaleString( me.log(Number(0+v).toPrecision(15));
['en-US'],
{
useGrouping: false,
maximumSignificantDigits: 15,
}
));
}, },
powR: Math.pow, powR: Math.pow,
...@@ -587,23 +581,11 @@ class ABCInterpreter { ...@@ -587,23 +581,11 @@ class ABCInterpreter {
lnR: Math.log, lnR: Math.log,
log10R: Math.log10, log10R: Math.log10,
RtoAC_words_needed: function(v) { RtoAC_words_needed: function(v) {
v=Number(0+v).toLocaleString( v=Number(0+v).toPrecision(15);
['en-US'],
{
useGrouping: false,
maximumSignificantDigits: 15,
}
);
return 2+((v.length+7)>>3); return 2+((v.length+7)>>3);
}, },
RtoAC: function (dest, v) { RtoAC: function (dest, v) {
v=Number(0+v).toLocaleString( v=Number(0+v).toPrecision(15);
['en-US'],
{
useGrouping: false,
maximumSignificantDigits: 15,
}
);
me.memory_array[dest/4]=6*8+2; // __STRING__ me.memory_array[dest/4]=6*8+2; // __STRING__
me.memory_array[dest/4+1]=0; me.memory_array[dest/4+1]=0;
me.memory_array[dest/4+2]=v.length; me.memory_array[dest/4+2]=v.length;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment