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 +49 -38
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/esm/maths/numeric.js +49 -38
- package/esm/maths/numeric.js.map +1 -1
- package/package.json +1 -1
- package/src/maths/numeric.ts +49 -48
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 =
|
|
7002
|
-
|
|
7003
|
-
//
|
|
7004
|
-
//
|
|
7005
|
-
//
|
|
7006
|
-
//
|
|
7007
|
-
//
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
}
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
const
|
|
7022
|
-
const
|
|
7023
|
-
if
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
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)) {
|