tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH] Fix printf(1) for integer larger than INTMAX_MAX



Hi,

Currently, printf(1) fails for integer larger than INTMAX_MAX as:

	$ printf '%d\n' 0xffffc00000000000
	printf: 0xffffc00000000000: Result too large or too small
	9223372036854775807

With this patch,

	http://www.netbsd.org/~rin/printf_20201024.patch

it becomes working as expected:

	$ printf '%d\n' 0xffffc00000000000
	-70368744177664

However, this result apparently depends on width of intmax_t. Is this
behavior acceptable by POSIX?

I think intmax_t is 64bit-width for all platforms that we currently
support. But, test cases (included in the patch above) can assume this?
If not, how can we obtain sizeof(intmax_t) from portable shell scripts?

Thanks,
rin


Home | Main Index | Thread Index | Old Index