Skip to content

Commit 72937b7

Browse files
authored
Use '0'+n for converting single digit to char (#521)
1 parent 8ac1498 commit 72937b7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

ext/bigdecimal/bigdecimal.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5396,8 +5396,8 @@ VpSzMantissa(Real *a, char *buf, size_t buflen)
53965396
while (m) {
53975397
nn = e / m;
53985398
if (!ZeroSup || nn) {
5399-
snprintf(buf, buflen, "%lu", (unsigned long)nn); /* The leading zero(s) */
5400-
buf += strlen(buf);
5399+
*buf = (char)('0' + nn);
5400+
buf++;
54015401
/* as 0.00xx will be ignored. */
54025402
ZeroSup = 0; /* Set to print succeeding zeros */
54035403
}
@@ -5504,10 +5504,8 @@ VpToString(Real *a, char *buf, size_t buflen, size_t fFmt, int fPlus)
55045504
while (m) {
55055505
nn = e / m;
55065506
if (!ZeroSup || nn) {
5507-
size_t n = Vp_ulltoa(nn, ulltoa_buf_end - 1);
5508-
if (n > plen) goto overflow;
5509-
MEMCPY(p, ulltoa_buf_end - n, char, n);
5510-
ADVANCE(n);
5507+
*p = (char)('0' + nn);
5508+
ADVANCE(1);
55115509

55125510
/* as 0.00xx will be ignored. */
55135511
ZeroSup = 0; /* Set to print succeeding zeros */

0 commit comments

Comments
 (0)