example-printf64.c 630 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include <stdint.h>
#include <pp-printf.h>

int main(int argc, char **argv)
{
	long long ll; /* I'd use "int64_t" but gcc wars about formats */

	for (ll = 1000; ll < (1LL << 61); ll *= 1000) {
		pp_printf("positive:     %20lli\n", ll);
		pp_printf("negative:     %20lli\n", -ll);
		pp_printf("neg-unsigned: %20llu\n", -ll);
		pp_printf("pos-hex:        0x%016llx\n", ll);
		pp_printf("pos-HEX:        0x%016llX\n", ll);
		pp_printf("neg-hex:        0x%016Lx\n", -ll);
		pp_printf("\n");
	}
	ll = (1LL <<63) - 1;
	pp_printf("max positive: %20lli\n", ll);
	ll = (1LL << 63);
	pp_printf("max negative: %20lli\n", ll);

	return 0;
}