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!mx02.eternal-september.org!.POSTED!not-for-mail From: Bob Duff Newsgroups: comp.lang.ada Subject: Re: Representation clauses and side-efects on STM32F411 ravenscar runtime Date: Sun, 02 Aug 2015 16:13:52 -0400 Organization: A noiseless patient Spider Message-ID: <87egjlla7z.fsf@theworld.com> References: <55bddbe2$0$3384$426a74cc@news.free.fr> <87io8xlb3p.fsf@theworld.com> <55be7728$0$3323$426a34cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="b05f112282df9bf71fe0f7c97bbe5fae"; logging-data="12302"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+W3bYAjhUz9GvHYuS/1Zkn" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:9ZYQdr4piYAqzkjNajaLzTSGM4E= sha1:C8j5K19mH8F76MP0dZks/ZdWHF8= Xref: news.eternal-september.org comp.lang.ada:27336 Date: 2015-08-02T16:13:52-04:00 List-Id: Frédéric Praca writes: > Le Sun, 02 Aug 2015 15:54:50 -0400, Bob Duff a écrit : > >> "Jeffrey R. Carter" writes: >> >>> On 08/02/2015 01:59 AM, Frédéric Praca wrote: >>>> >>>> type Mantissa is range 0 .. 2**12 - 1 with Size => 12; >>>> type Fraction is range 0 .. 2**4 - 1 with Size => 4; >> >> Note that the Sizes will be 12 and 4 by default. >> >>> Wouldn't modular types be better for these? >> >> Why would you want wraparound arithmetic for these? Seems like it would >> just hide bugs. > > I fully agree. Mantissa and Fraction don't have to use wraparound > arithmetic. In fact, these two variables together represent a fixed point > type and the magic must be inside the functions which calculates these > variables according to the bus frequency and by the way must take care of > the carry and possible overflow. Then would a fixed-point type work? type Baud_Rate is delta 1.0/16 range ...; for Baud_Rate'Small use 1.0/16; - Bob