Modular arithmetic: Difference between revisions

m
Line 87:
I would be tempted to say that supporting modulus 2**(wordsize) amounts to transparently supporting both modular and non-modular integers. It is, after all, the normal arithmetic of the language. However, 10**100 would overflow the register. There is, in fact, with C semantics, no way to do non-modular arithmetic with unsigned integers of fixed size! You automatically get 2**(wordsize) as a modulus.
 
(''Aside: A definition of f(x) that worked with signed integers, floating point, etc., as well, would have to be a macro. This is possible because of the overloading of the operators. Alternatively, you could introduce a'' <code>datatype</code> ''for "real numbers of different kinds", and write f(x) to work with that less efficient type.'')
 
<syntaxhighlight lang="ATS">
1,448

edits