On 8 Jul 2014, at 8:24 pm, tgingold@free.fr wrote: > Well, the arithmetic is not the same. Eg: (3 + 1) mod 3 > > For a signed type, the result is 1. > For a modular type with a modulus of 4, the result is 0. And they aren't meant to return the same value. 3.5.4 Integer Types http://www.adaic.org/resources/add_content/standards/05rm/html/RM-3-5-4.html For every modular subtype S, the following attributes are defined: S'Mod S'Mod denotes a function with the following specification: function S'Mod (Arg : universal_integer) return S'Base This function returns Arg mod S'Modulus, as a value of the type of S. S'Modulus S'Modulus yields the modulus of the type of S, as a value of the type universal_integer. The 'Mod attribute is a function that performs modulus reduction for the type of S. Ada's modular integers use 0 as 'LOW bound (also from 3.5.4): "...The set of values for a modular integer type are the values from 0 to one less than the modulus, inclusive." 3 is a valid value of the modular type, as is 0: type mod4 is mod 4; That two bit counter counts "0, 1, 2, 3, 0,...". 3 isn't a valid value for a modular type defined mod 3. If you wanted the same answer you could have used the same modulus. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Thu Jul 10 20:23:10 2014
This archive was generated by hypermail 2.1.8 : Thu Jul 10 2014 - 20:24:03 PDT