I'm implementing a fixed point arithmetic, in C, which extends the format of the usual C types.
for example... you know that the greatest size allowed by C integer types is 8 bytes.
My extension works in this way
typedef struct fixed_point {
unsigned long long int chunk[CHUNK_ELEMENT];
} fixed_point;
where basically CHUNK_ELEMENT is set by a macro statement, so when i compile i have my specific version of fixed point stuff.
I choose this way of implementation (i.e. embodie an array into a struct) because make easier the implementation of stuff like
fixed_point sum(fixed_point __x, fixed_point __y);
My question is it is efficient to implement the stuff in this way? Instead i could work straight with the array defining
typedef unsigned long long int[BIT_CHUNK_SIZE] fixed_point
but in this case i should implement stuff like
void sum(fixed_point* __z, fixed_point __x, fixed_point __y);
which is pretty tedious from syntax point of view.
What do you think?
(PS. I'm implementing all basic operator <<,>>,&,|,^,+,-,*,/ etc)