Skip to content

Commit a14c2d7

Browse files
author
rafaelk
committed
NaN values with 'd' switch are translated to 0
1 parent 33ab4dc commit a14c2d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

functions/strings/sprintf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function sprintf ( ) {
124124
case 'u': return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
125125
case 'i':
126126
case 'd':
127-
number = parseInt(+value, 10);
127+
number = (+value) | 0;
128128
prefix = number < 0 ? '-' : positivePrefix;
129129
value = prefix + pad(String(Math.abs(number)), precision, '0', false);
130130
return justify(value, prefix, leftJustify, minWidth, zeroPad);

0 commit comments

Comments
 (0)