figbertmath

[RADIOACTIVE] miscellaneous math programs in website form
git clone git://git.figbert.com/figbertmath.git
Log | Files | Refs | README

commit 002b63ef7c951f0b5f8e472b901f882319d4c54a
parent 860e88d83b9e32e9db4f1a56d7e23b6e16592b0e
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Thu,  5 Dec 2019 19:27:59 -0800

Round all output to two decimal points, add variable names to the output screen

Now outputs are rounded and converted to strings (in order to add equal 
signs) before being submitted to CalcOut to be displayed.

Diffstat:
Msrc/components/highLevel/simultaneousEquation.js | 15+++++++++++++++
1 file changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/components/highLevel/simultaneousEquation.js b/src/components/highLevel/simultaneousEquation.js @@ -158,6 +158,21 @@ export class SimultaneousEquation extends React.Component { } } + //Round each number to four decimal places + const alphabet = (function(charA, charZ) { + let a = [], i = charA.charCodeAt(0), j = charZ.charCodeAt(0); + for (; i <= j; ++i) { + a.push(String.fromCharCode(i)); + } + return a; + }('a', 'z')); + for (let i = 0; i < sums.length; i++) { + if (sums[i] % 1 !== 0) { + sums[i] = Math.round((sums[i] + 0.00001) * 100) / 100; + } + sums[i] = alphabet[i] + ' = ' + sums[i]; + } + //Set the output to the array of values this.setState({ output: sums