C
cps
I am considering writing an int128 class as a programming exercise.
Before I start (and I have a fair idea of how to do it) I was
wondering what I can do about literals and the assignment operator. I
would like to be able to use integer literals with the assignment and
other operators with literals that are sized at 128 bits.
E.g. I'd like to be able to do:
uint128 myInt128 = 184467440737095516160;
Note that the foregoing literal would produce an error (correctly
so) if I attempted to assign it to an uint64 because it is (2^64) *
10.
Is there any way I can set it up to deal with large literals?
Or am I going to have to use strings and parse them?
Before I start (and I have a fair idea of how to do it) I was
wondering what I can do about literals and the assignment operator. I
would like to be able to use integer literals with the assignment and
other operators with literals that are sized at 128 bits.
E.g. I'd like to be able to do:
uint128 myInt128 = 184467440737095516160;
Note that the foregoing literal would produce an error (correctly
so) if I attempted to assign it to an uint64 because it is (2^64) *
10.
Is there any way I can set it up to deal with large literals?
Or am I going to have to use strings and parse them?