summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/floatio.h
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2003-04-05 22:03:43 +0000
committerdas <das@FreeBSD.org>2003-04-05 22:03:43 +0000
commitc0e486bd07885ad47b68f40cdb8d55c8811ed08a (patch)
tree826bf02ef4bdb923996387c17705464f14a5d35d /lib/libc/stdio/floatio.h
parentc0badd1444fc63c006a6fdf38d80d02fa22aa919 (diff)
downloadFreeBSD-src-c0e486bd07885ad47b68f40cdb8d55c8811ed08a.zip
FreeBSD-src-c0e486bd07885ad47b68f40cdb8d55c8811ed08a.tar.gz
Correct some buffer sizes.
- __vfprintf()'s 'buf' has never been used for floating point, so don't define it in terms of (incorrect) constants describing floating point numbers. The actual size needed depends on sizeof(uintmax_t) and locale details, so I slightly overestimated. - We don't need a 308-character buffer to store the string "308". With long doubles and %a we need more than three characters, though.
Diffstat (limited to 'lib/libc/stdio/floatio.h')
-rw-r--r--lib/libc/stdio/floatio.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libc/stdio/floatio.h b/lib/libc/stdio/floatio.h
index a40df00..22fedcd 100644
--- a/lib/libc/stdio/floatio.h
+++ b/lib/libc/stdio/floatio.h
@@ -41,7 +41,14 @@
* Floating point scanf/printf (input/output) definitions.
*/
-/* 11-bit exponent (VAX G floating point) is 308 decimal digits */
-#define MAXEXP 308
-/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */
-#define MAXFRACT 39
+/*
+ * MAXEXPDIG is the maximum number of decimal digits needed to store a
+ * floating point exponent in the largest supported format. It should
+ * be ceil(log10(LDBL_MAX_10_EXP)) or, if hexadecimal floating point
+ * conversions are supported, ceil(log10(LDBL_MAX_EXP)). But since it
+ * is presently never greater than 5 in practice, we fudge it.
+ */
+#define MAXEXPDIG 6
+#if LDBL_MAX_EXP > 999999
+#error "floating point buffers too small"
+#endif
OpenPOWER on IntegriCloud