Merge pull request #12722 from calixteman/printf
JS -- fix printd issue with negative number
This commit is contained in:
commit
85ab53fef0
@ -154,9 +154,9 @@ class Util extends PDFObject {
|
|||||||
let decPart = "";
|
let decPart = "";
|
||||||
if (cConvChar === "f") {
|
if (cConvChar === "f") {
|
||||||
if (nPrecision !== undefined) {
|
if (nPrecision !== undefined) {
|
||||||
decPart = (arg - intPart).toFixed(nPrecision);
|
decPart = Math.abs(arg - intPart).toFixed(nPrecision);
|
||||||
} else {
|
} else {
|
||||||
decPart = (arg - intPart).toString();
|
decPart = Math.abs(arg - intPart).toString();
|
||||||
}
|
}
|
||||||
if (decPart.length > 2) {
|
if (decPart.length > 2) {
|
||||||
decPart = `${decimalSep}${decPart.substring(2)}`;
|
decPart = `${decimalSep}${decPart.substring(2)}`;
|
||||||
|
@ -209,6 +209,11 @@ describe("Scripting", function () {
|
|||||||
expect(value).toEqual("Decimal number: + 1.235");
|
expect(value).toEqual("Decimal number: + 1.235");
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
myeval(`util.printf("Decimal number: %,0.2f", -12.34567)`).then(
|
||||||
|
value => {
|
||||||
|
expect(value).toEqual("Decimal number: -12.35");
|
||||||
|
}
|
||||||
|
),
|
||||||
]).then(() => done());
|
]).then(() => done());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user