If you need your own data types (regardless of whether it is suitable for mathematics, etc.), you need to return to structures and functions. For instance:
struct bignum_s { char bignum_data[1024]; }
(obviously, you want to get the right sizing, this is just an example)
Most people end up also typing it:
typedef struct bignum_s bignum;
And then create functions that take two (or any) pointers to numbers to do what you want:
void bignum_or(bignum *a, bignum *b) { int i; for(i = 0; i < sizeof(a->bignum_data); i++) { a->bignum_data[i] |= b->bignum_data[i]; } }
You really want to define almost all the functions that you might need, and this often includes memory allocation functions ( bignum_new ), memory deallocation functions ( bignum_free ), and initialization procedures ( bignum_init ). Even if you don’t need them now, do it in advance to determine when the code should grow and develop later.
source share