From a39951d8f69209cfea2b7051832b851914e662ef Mon Sep 17 00:00:00 2001 From: rodri Date: Sat, 22 Feb 2020 09:56:09 +0000 Subject: now version controlled. --- bitround.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 bitround.c (limited to 'bitround.c') diff --git a/bitround.c b/bitround.c new file mode 100644 index 0000000..4602387 --- /dev/null +++ b/bitround.c @@ -0,0 +1,25 @@ +#include +#include + +#define round(s, sz) ((s)+((sz)-1)&~((sz)-1)) + +static void +usage(void) +{ + fprint(2, "usage: bitround number\n"); + exits("usage"); +} + +void +main(int argc, char *argv[]) +{ + int i; + + if(argc != 2) + usage(); + i = strtol(argv[1], nil, 0); + print("i0 %b (%d)\n", i, i); + i = round(i, sizeof(int)); + print("i1 %b (%d)\n", i, i); + exits(0); +} -- cgit v1.2.3