1131447Stjr/* inttostr.h -- convert integers to printable strings 2131447Stjr 3133543Stjr Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. 4131447Stjr 5131447Stjr This program is free software; you can redistribute it and/or modify 6131447Stjr it under the terms of the GNU General Public License as published by 7131447Stjr the Free Software Foundation; either version 2, or (at your option) 8131447Stjr any later version. 9131447Stjr 10131447Stjr This program is distributed in the hope that it will be useful, 11131447Stjr but WITHOUT ANY WARRANTY; without even the implied warranty of 12131447Stjr MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13131447Stjr GNU General Public License for more details. 14131447Stjr 15131447Stjr You should have received a copy of the GNU General Public License 16131447Stjr along with this program; if not, write to the Free Software Foundation, 17131447Stjr Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 18131447Stjr 19131447Stjr/* Written by Paul Eggert */ 20131447Stjr 21131447Stjr#if HAVE_CONFIG_H 22131447Stjr# include <config.h> 23131447Stjr#endif 24131447Stjr 25131447Stjr#if HAVE_INTTYPES_H 26131447Stjr# include <inttypes.h> 27131447Stjr#endif 28133543Stjr#if HAVE_STDINT_H 29133543Stjr# include <stdint.h> 30131447Stjr#endif 31131447Stjr 32133543Stjr#include <limits.h> 33133543Stjr 34131447Stjr#if HAVE_SYS_TYPES_H 35131447Stjr# include <sys/types.h> 36131447Stjr#endif 37131447Stjr 38131447Stjr/* Upper bound on the string length of an integer converted to string. 39131447Stjr 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit; 40131447Stjr add 1 for integer division truncation; add 1 more for a minus sign. */ 41131447Stjr#define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2) 42131447Stjr 43131447Stjr#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) 44131447Stjr 45131447Stjrchar *offtostr (off_t, char *); 46131447Stjrchar *imaxtostr (intmax_t, char *); 47131447Stjrchar *umaxtostr (uintmax_t, char *); 48