/*
  $Id: num.c 3113 2024-09-06 16:17:07Z darcy $
  Written by D'Arcy J.M. Cain
  darcy@druid.net

  Here is a little program which reads a number in and gives it back in
  binary, octal, hex and decimal forms. The input can be in decimal, octal
  (leading 0) or hex (leading 0x.)  Note that this is highly simplified.
*/

#include	"cain.h"

#include	<stdlib.h>
#include	<limits.h>

int
main(void)
{
	char		*p;
	long long	k;
	long long	v, x;

	while ((p = cgetline(stdin, 0)) != NULL)
	{
		v = strtol(p, NULL, 0);

		for (x = v, k = 0; k < 64; k++)
		{
			putchar(x & 0x8000000000000000ll ? '1' : '0');
			x <<= 1;
		}

		printf("b\n    %024llo 0x%016llx %20lld\n", v, v, v);
	}

	return(0);
}
