Begun work on bignums; changed integer size to 64 bits

I'm fairly sure the size of a long int on my machines is 64 bit anyway, but for portability it needs to be explicit.
This commit is contained in:
Simon Brooke 2018-12-25 13:18:37 +00:00
parent ad9b1cd7f8
commit 6ee9f9b59a
13 changed files with 109 additions and 25 deletions

View file

@ -1,9 +1,26 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TAGLENGTH 4
struct dummy {
union {
char bytes[TAGLENGTH]; /* the tag (type) of this cell,
* considered as bytes */
uint32_t value; /* the tag considered as a number */
} tag;
};
int main( int argc, char *argv[] ) {
struct dummy *b = malloc( sizeof( struct dummy));
struct dummy buffer = *b;
for (int i = 1; i < argc; i++) {
printf( "%4.4s:\t%u\n", argv[i], (uint32_t)*argv[i]);
strncpy( &buffer.tag.bytes[0], argv[i], TAGLENGTH );
printf( "%4.4s:\t%d\n", argv[i], buffer.tag.value);
}
}

Binary file not shown.