@@ -9,7 +9,7 @@ export class HyperMath {
99 console . warn ( 'Invalid input provided:' , value ) ;
1010 return 0 ;
1111 }
12- value = parseFloat ( parseFloat ( value ) . toPrecision ( 2 ) ) ;
12+ value = parseFloat ( parseFloat ( value ) . toFixed ( 2 ) ) ;
1313 }
1414 return value ;
1515 }
@@ -20,10 +20,10 @@ export class HyperMath {
2020 ) : number {
2121 let a = this . processInput ( firstValue ) ;
2222 let b = this . processInput ( secondValue ) ;
23- let numberOne = parseFloat ( a . toPrecision ( 2 ) ) ;
24- let numberTwo = parseFloat ( b . toPrecision ( 2 ) ) ;
23+ let numberOne = parseFloat ( a . toFixed ( 2 ) ) ;
24+ let numberTwo = parseFloat ( b . toFixed ( 2 ) ) ;
2525 let result = numberOne * numberTwo ;
26- result = parseFloat ( result . toPrecision ( 2 ) ) ;
26+ result = parseFloat ( result . toFixed ( 2 ) ) ;
2727 return result ;
2828 }
2929
@@ -33,10 +33,10 @@ export class HyperMath {
3333 ) : number {
3434 let a = this . processInput ( firstValue ) ;
3535 let b = this . processInput ( secondValue ) ;
36- let numberOne = parseFloat ( a . toPrecision ( 2 ) ) ;
37- let numberTwo = parseFloat ( b . toPrecision ( 2 ) ) ;
36+ let numberOne = parseFloat ( a . toFixed ( 2 ) ) ;
37+ let numberTwo = parseFloat ( b . toFixed ( 2 ) ) ;
3838 let result = numberOne + numberTwo ;
39- result = parseFloat ( result . toPrecision ( 2 ) ) ;
39+ result = parseFloat ( result . toFixed ( 2 ) ) ;
4040 return result ;
4141 }
4242
@@ -49,10 +49,10 @@ export class HyperMath {
4949 if ( a === 0 || b === 0 ) {
5050 return 0 ;
5151 }
52- let numberOne = parseFloat ( a . toPrecision ( 2 ) ) ;
53- let numberTwo = parseFloat ( b . toPrecision ( 2 ) ) ;
52+ let numberOne = parseFloat ( a . toFixed ( 2 ) ) ;
53+ let numberTwo = parseFloat ( b . toFixed ( 2 ) ) ;
5454 let result = numberOne / numberTwo ;
55- result = parseFloat ( result . toPrecision ( 2 ) ) ;
55+ result = parseFloat ( result . toFixed ( 2 ) ) ;
5656 return result ;
5757 }
5858
@@ -65,10 +65,10 @@ export class HyperMath {
6565 if ( a === 0 ) {
6666 return 0 ;
6767 }
68- let numberOne = parseFloat ( a . toPrecision ( 2 ) ) ;
69- let numberTwo = parseFloat ( b . toPrecision ( 2 ) ) ;
68+ let numberOne = parseFloat ( a . toFixed ( 2 ) ) ;
69+ let numberTwo = parseFloat ( b . toFixed ( 2 ) ) ;
7070 let result = numberOne - numberTwo ;
71- result = parseFloat ( result . toPrecision ( 2 ) ) ;
71+ result = parseFloat ( result . toFixed ( 2 ) ) ;
7272 return result ;
7373 }
7474}
0 commit comments