mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
[JS] Correctly format floating numbers when they're close to an integer (bug 1918115)
This commit is contained in:
parent
870394d22b
commit
ca95264e8b
4 changed files with 35 additions and 1 deletions
|
@ -153,7 +153,12 @@ class Util extends PDFObject {
|
|||
? Math.abs(arg - intPart).toFixed(nPrecision)
|
||||
: Math.abs(arg - intPart).toString();
|
||||
if (decPart.length > 2) {
|
||||
decPart = `${decimalSep}${decPart.substring(2)}`;
|
||||
if (/^1\.0+$/.test(decPart)) {
|
||||
intPart += Math.sign(arg);
|
||||
decPart = `${decimalSep}${decPart.split(".")[1]}`;
|
||||
} else {
|
||||
decPart = `${decimalSep}${decPart.substring(2)}`;
|
||||
}
|
||||
} else {
|
||||
if (decPart === "1") {
|
||||
intPart += Math.sign(arg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue