comp.lang.ada
 help / color / mirror / Atom feed
From: Bob Duff <bobduff@theworld.com>
Subject: Re: Representation clauses and side-efects on STM32F411 ravenscar runtime
Date: Sun, 02 Aug 2015 16:13:52 -0400
Date: 2015-08-02T16:13:52-04:00	[thread overview]
Message-ID: <87egjlla7z.fsf@theworld.com> (raw)
In-Reply-To: 55be7728$0$3323$426a34cc@news.free.fr

Frédéric Praca <frederic.praca@free.fr> writes:

> Le Sun, 02 Aug 2015 15:54:50 -0400, Bob Duff a écrit :
>
>> "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> 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

  reply	other threads:[~2015-08-02 20:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-02  8:59 Representation clauses and side-efects on STM32F411 ravenscar runtime Frédéric Praca
2015-08-02  9:40 ` Simon Wright
2015-08-02 10:22   ` Simon Wright
2015-08-02 14:53     ` Frédéric Praca
2015-08-02 14:52   ` Frédéric Praca
2015-08-02 15:19     ` Simon Wright
2015-08-02 19:23 ` Jeffrey R. Carter
2015-08-02 19:54   ` Bob Duff
2015-08-02 20:01     ` Frédéric Praca
2015-08-02 20:13       ` Bob Duff [this message]
2015-08-02 20:27         ` Frédéric Praca
2015-08-02 20:31     ` Jeffrey R. Carter
2015-08-03 11:08 ` Simon Clubley
2015-08-15 14:22   ` Frédéric Praca
2015-08-15 15:33     ` Simon Clubley
2015-08-15 17:17       ` Frédéric Praca
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox