musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/stdio/vfprintf.c 4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
index a68edabb..514a44dd 100644
--- a/src/stdio/vfprintf.c
+++ b/src/stdio/vfprintf.c
@@ -182,7 +182,9 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t, int ps)
{
int max_mant_dig = (ps==BIGLPRE) ? LDBL_MANT_DIG : DBL_MANT_DIG;
int max_exp = (ps==BIGLPRE) ? LDBL_MAX_EXP : DBL_MAX_EXP;
- int max_mant_slots = (max_mant_dig+28)/29 + 1;
+ /* One slot for 29 bits left of radix point, a slot for every 29-21=8
+ * bits right of the radix point, and one final zero slot. */
+ int max_mant_slots = 1 + (max_mant_dig-29+7)/8 + 1;
int max_exp_slots = (max_exp+max_mant_dig+28+8)/9;
int bufsize = max_mant_slots + max_exp_slots;
uint32_t big[bufsize];
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月26日 13:13:38 +0000

AltStyle によって変換されたページ (->オリジナル) /