J
John Devereux
I was wondering what is the "best" way to set a variable to "all
ones". In particular where I do not know the precise type of the
variable (or more accurately, when I don't want to worry about it!).
E.g. assume "a" is unsigned, but could be char, short, int or long.
a = -1;
or
a = ~0;
Would these always work? (I only care about machines with 2's
complement arithmetic).
Thanks,
ones". In particular where I do not know the precise type of the
variable (or more accurately, when I don't want to worry about it!).
E.g. assume "a" is unsigned, but could be char, short, int or long.
a = -1;
or
a = ~0;
Would these always work? (I only care about machines with 2's
complement arithmetic).
Thanks,