Skip to content

Commit c547242

Browse files
authored
Update hk.htm
1 parent 61b990b commit c547242

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

hk.htm

+16-2
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,22 @@
203203
}
204204

205205

206-
function fmtDecimal(n) {
207-
return n.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
206+
function fmtDecimal(num) {
207+
// Multiply by 1000 to shift the decimal point
208+
const shifted = Math.round(num * 1000);
209+
210+
// Extract the first two decimal places
211+
const wholePart = Math.floor(shifted / 10); // Get the whole number part
212+
const decimalPart = shifted % 10; // Get the third decimal place
213+
214+
// If the third decimal place is greater than 1, add it to the second decimal place
215+
if (decimalPart > 1) {
216+
newNum = (wholePart + 1) / 100; // Add 1 to the second decimal place
217+
} else {
218+
newNum = wholePart / 100; // Just return the number with two decimal places
219+
}
220+
221+
return newNum.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
208222
}
209223

210224

0 commit comments

Comments
 (0)