pimath 0.0.119 → 0.0.120

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pi.js CHANGED
@@ -6998,44 +6998,55 @@ class Numeric {
6998
6998
  }
6999
6999
  return triplets;
7000
7000
  }
7001
- static numberCorrection(value, epsilonDigit = 1, epsilonNumberOfDigits = 10, number_of_digits = 6) {
7002
- // Must modify the number if it's like:
7003
- // a: 3.0000000000000003
7004
- // b: 3.9999999999999994
7005
- // remove the last character
7006
- // check if around n last characters are either 0 or 9
7007
- // if it is, 'round' the number.
7008
- function extractDecimalPart(valueToExtract, decimalLength) {
7009
- let decimal = valueToExtract.toString();
7010
- if (!decimal.includes('.')) {
7011
- return '';
7012
- }
7013
- decimal = decimal.split('.')[1];
7014
- return decimal.substring(0, decimalLength);
7015
- }
7016
- const epsilon = Number(`0.${"0".repeat(epsilonNumberOfDigits - 1)}${epsilonDigit}`);
7017
- const decimal = extractDecimalPart(value, epsilonNumberOfDigits);
7018
- if (decimal === '') {
7019
- return value;
7020
- }
7021
- const n9 = decimal.match(/9+$/g);
7022
- const n0 = decimal.match(/0+$/g);
7023
- if (n9 && n9[0].length >= number_of_digits) {
7024
- // New tested values.
7025
- const mod = extractDecimalPart(value + epsilon, epsilonNumberOfDigits), mod0 = mod.match(/0+$/g);
7026
- if (mod0 && mod0[0].length >= number_of_digits) {
7027
- return +((value + epsilon).toString().split(mod0[0])[0]);
7028
- }
7029
- }
7030
- if (n0 && n0[0].length >= number_of_digits) {
7031
- // New tested values.
7032
- const mod = extractDecimalPart(value - epsilon, epsilonNumberOfDigits), mod9 = mod.match(/9+$/g);
7033
- if (mod9 && mod9[0].length >= number_of_digits) {
7034
- // The value can be changed. Remove all nines!
7035
- return +(value.toString().split(n0[0])[0]);
7036
- }
7037
- }
7038
- return value;
7001
+ static numberCorrection(value, epsilonDigit = 1, epsilonNumberOfDigits = 10, number_of_digits = 8) {
7002
+ return +value.toFixed(number_of_digits);
7003
+ //
7004
+ // // Must modify the number if it's like:
7005
+ // // a: 3.0000000000000003
7006
+ // // b: 3.9999999999999994
7007
+ // // remove the last character
7008
+ // // check if around n last characters are either 0 or 9
7009
+ // // if it is, 'round' the number.
7010
+ // function extractDecimalPart(valueToExtract: number, decimalLength: number){
7011
+ // let decimal = valueToExtract.toString()
7012
+ //
7013
+ // if (!decimal.includes('.')) {
7014
+ // return ''
7015
+ // }
7016
+ //
7017
+ // decimal = decimal.split('.')[1]
7018
+ // return decimal.substring(0, decimalLength)
7019
+ // }
7020
+ //
7021
+ // const epsilon = Number(`0.${"0".repeat(epsilonNumberOfDigits-1)}${epsilonDigit}`)
7022
+ // const decimal = extractDecimalPart(value, epsilonNumberOfDigits)
7023
+ // if(decimal===''){return value}
7024
+ //
7025
+ // const n9 = decimal.match(/9+$/g)
7026
+ // const n0 = decimal.match(/0+$/g)
7027
+ //
7028
+ // if (n9 && n9[0].length >= number_of_digits) {
7029
+ // // New tested values.
7030
+ // const mod = extractDecimalPart(value + epsilon, epsilonNumberOfDigits),
7031
+ // mod0 = mod.match(/0+$/g)
7032
+ //
7033
+ // if(mod0 && mod0[0].length>= number_of_digits){
7034
+ // return +((value+epsilon).toString().split(mod0[0])[0])
7035
+ // }
7036
+ // }
7037
+ //
7038
+ // if (n0 && n0[0].length >= number_of_digits) {
7039
+ // // New tested values.
7040
+ // const mod = extractDecimalPart(value - epsilon, epsilonNumberOfDigits),
7041
+ // mod9 = mod.match(/9+$/g)
7042
+ //
7043
+ // if(mod9 && mod9[0].length>= number_of_digits){
7044
+ // // The value can be changed. Remove all nines!
7045
+ // return +(value.toString().split(n0[0])[0])
7046
+ // }
7047
+ // }
7048
+ //
7049
+ // return value
7039
7050
  }
7040
7051
  static periodic(value) {
7041
7052
  if (Number.isSafeInteger(value)) {