zmdms-utils 0.0.84 → 0.0.85

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/es/math.js CHANGED
@@ -132,11 +132,14 @@ function exactRound(num, ratio) {
132
132
  var _b = str.split("."), intPart = _b[0], decimalPart = _b[1];
133
133
  // 确保小数部分至少有precision位,不足则补0
134
134
  var paddedDecimal = decimalPart;
135
- if (paddedDecimal.length > exactRoundTypePrecision) {
135
+ if (paddedDecimal.length < exactRoundTypePrecision) {
136
136
  paddedDecimal = paddedDecimal.padEnd(exactRoundTypePrecision, "0");
137
137
  }
138
138
  value = "".concat(intPart, ".").concat(paddedDecimal);
139
139
  }
140
+ else {
141
+ value = new Decimal(value).toFixed(exactRoundTypePrecision);
142
+ }
140
143
  }
141
144
  return value;
142
145
  // return Number(num).toFixed(ratio);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.84",
3
+ "version": "0.0.85",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/math.ts CHANGED
@@ -135,10 +135,12 @@ export function exactRound(num: numType, ratio: number) {
135
135
  const [intPart, decimalPart] = str.split(".");
136
136
  // 确保小数部分至少有precision位,不足则补0
137
137
  let paddedDecimal = decimalPart;
138
- if (paddedDecimal.length > exactRoundTypePrecision) {
138
+ if (paddedDecimal.length < exactRoundTypePrecision) {
139
139
  paddedDecimal = paddedDecimal.padEnd(exactRoundTypePrecision, "0");
140
140
  }
141
141
  value = `${intPart}.${paddedDecimal}`;
142
+ } else {
143
+ value = new Decimal(value).toFixed(exactRoundTypePrecision);
142
144
  }
143
145
  }
144
146
  return value;