From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!mnetor!uunet!husc6!bbn!inmet!ishmael!inmet!ada-uts!stt From: stt@ada-uts Newsgroups: comp.lang.ada Subject: Re: unsigned integers in Ada Message-ID: <57900067@ada-uts> Date: 26 Apr 88 14:32:00 GMT References: <25160@clyde.ATT.COM> Nf-ID: #R:clyde.ATT.COM:-2516000:ada-uts:57900067:000:1600 Nf-From: ada-uts!stt Apr 26 10:32:00 1988 List-Id: Ada requires that all predefined integer types be symmetric about zero, excepting an extra negative value (LRM 3.5.4:7), and that all integer types be derived directly or indirectly from one of these. However, it would be permissible to define a LONG_INTEGER which is signed 64 bits, and then define a subtype of that which is unsigned 32 bits, and implement it using unsigned 32 bit representation in memory (though the arithmetic would still have to allow 64-bit intermediate results without NUMERIC_ERROR). Representation clauses are only allowed for "first named subtypes" (defined in LRM 13.1:3). The first named subtype is the subtype identified in a "type definition." The type is generally anonymous and unconstrained; the identifier specified designates a subtype. For example type My_Int is range 0..15; This is formally equivalent to (see LRM 3.5.4:5,6): type is new ; subtype My_Int is range 0..15; "My_Int" is therefore the "first named subtype." Allowing unsigned types in general has been proposed as a possible addition for the next revision of Ada, but beware that it would imply NUMERIC_ERROR if the arithmetic result goes negative, rather than just wrapping around, as most "C" programmers expect. Furthermore, there would have to be a rule for deciding which predefined type is selected for any given integer type definition with a non-negative range (the signed one or the unsigned one), since this would determine the legality of negative intermediate arithmetic results. Tucker Taft Intermetrics, Inc. Cambridge, MA 02138