From 12cbeae3903a7d4787a03f55c6591f86e7b06164 Mon Sep 17 00:00:00 2001 From: Arthur David Olson Date: Sun, 30 May 1993 16:25:00 -0400 Subject: [PATCH] INT_STRLEN_MAXIMUM work SCCS-file: private.h SCCS-SID: 7.4 --- private.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/private.h b/private.h index 2b8a99c..cd8ea1a 100644 --- a/private.h +++ b/private.h @@ -162,7 +162,14 @@ extern void free P((char * buf)); #endif /* !defined FALSE */ #ifndef INT_STRLEN_MAXIMUM -#define INT_STRLEN_MAXIMUM (1 + (sizeof (int) * CHAR_BIT + 1) / 3) +/* +** 302 / 1000 is log10(2.0) rounded up. +** Subtract one for the sign bit; +** add one for integer division truncation; +** add one more for a minus sign. +*/ +#define INT_STRLEN_MAXIMUM(type) \ + ((sizeof(type) * CHAR_BIT - 1) * 302 / 1000 + 2) #endif /* !defined INT_STRLEN_MAXIMUM */ /*