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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: hreba Newsgroups: comp.lang.ada Subject: integers of 1, 2, 4 bytes Date: Sun, 15 Jun 2014 14:57:31 -0300 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 6hSfC1wiorHcqKrLxq1WRwOFP3zziE+pcWPuNlCNNUUUEiJ7Np Cancel-Lock: sha1:tBphlTs8q+2wEjCbDJ3tXdKPYBU= User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 Xref: news.eternal-september.org comp.lang.ada:20321 Date: 2014-06-15T14:57:31-03:00 List-Id: Hi, I want to translate some of my Oberon programs to Ada. So I need the Oberon types SHORTINT (1 byte), INTEGER (2 bytes) and LONGINT (4 bytes). A type BYTE (1 byte, values 0..255) would be useful too. In Oberon one uses CHAR for that. The most obvious translation for INTEGER would be type INT is range -32768 .. 32767; (all platforms I have been working on use the two's complement). My Ada book says that range checks are applied to constrained subtypes (like that one) but not to unconstrained subtypes, but but overflow checks are applied nevertheless. So I came up with type Int16 is range -32768 .. 32767; for Int16'Size use 16; type INT is new Int16'Base; as a more efficient definition. Now it seems the range specification doesn't matter any more and that I could equally write type Int16 is range -1 .. 1; for Int16'Size use 16; type INT is new Int16'Base; Would you really define a 16 bit integer type this way? And how about non-negative types? Would the following have the values 0 .. 255? type Nat8 is range 0..1; for Nat8'Size use 8; type BYTE is new Nat8'Base; -- Frank Hrebabetzky +55 / 48 / 3235 1106 Florianopolis, Brazil