File: prog.c

package info (click to toggle)
mk-configure 0.37.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,112 kB
  • sloc: ansic: 5,441; makefile: 1,412; sh: 1,086; cpp: 200; perl: 101; yacc: 85; lex: 21
file content (37 lines) | stat: -rw-r--r-- 649 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>

#include <mkc_humanize_number.h>
#include <mkc_err.h>

static void print(int64_t bytes)
{
	char buffer[9];
	if (-1 == humanize_number(
			buffer, sizeof(buffer),
			bytes, "", HN_AUTOSCALE, HN_B | HN_NOSPACE))
	{
		err(1, "humanize_number");
	}

	printf("%lu bytes is aproximately %s\n", (unsigned long)bytes, buffer);
}

int main(int argc, char **argv)
{
	print(1l);
	print(10l);
	print(100l);
	print(1000l);
	print(10000l);
	print(100000l);
	print(1000000l);
	print(10000000l);
	print(100000000l);
	print(1000000000l);
	print(10000000000l);
	print(100000000000l);
	print(1000000000000l);
	print(10000000000000l);

	return 0;
}