comp.lang.ada
 help / color / mirror / Atom feed
From: sjw <simon.j.wright@mac.com>
Subject: Re: conversions between fixed-point types
Date: Sun, 27 Sep 2009 12:22:38 -0700 (PDT)
Date: 2009-09-27T12:22:38-07:00	[thread overview]
Message-ID: <fff32aac-526a-4037-b40f-a4811ca730d0@e18g2000vbe.googlegroups.com> (raw)
In-Reply-To: h95trn$54e$1@news.albasani.net

On Sep 20, 7:55 pm, Dirk Herrmann <fight_s...@invalid.invalid> wrote:

> As I said when I started this thread, I am currently investigating whether Ada
> could be a good replacement for the proprietary fixed-point oriented language
> used in our company.  And, convincing my colleagues would certainly not be
> easier with statements like "Ada can be used, but you have to implement all
> fixed-point stuff yourself".  Even more if you can not even rely on the fact
> that a compiler will behave the same way throughout.

Is the target hardware standard? (eg, PPC without floating-point
support) If not, you're looking at a compiler port as well.

Even though GNAT/x86 seems to truncate on predefined operations and on
conversion from static values (though not, as far as I can tell, on
dynamic conversion between two types!), there seems no intrinsic
reason why a port to different hardware might not be made to round.

> Robert A Duff wrote:

> > By the way, you can say:
>
> >     for T'Small use T'Delta;
>
> > to avoid repeating yourself.
>
> I have tried that, especially since the very same recommendation was given in
> the Barnes book "Ada 2005".  But, GNAT gives an error message.  It seems that
> the very moment you reference T'Delta the type T gets "frozen" such that  the
> "use" statement itself freezes T before it can modify it.  I don't know if
> this is what the authors of the reference manual had intended, but GNAT
> interprets it that way.

The idiom used to the

T_Delta : constant := 0.4;
type T is delta T_Delta range -10.0 .. 10.0;
for T'Small use T_Delta;



  parent reply	other threads:[~2009-09-27 19:22 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-18 21:35 conversions between fixed-point types Dirk Herrmann
2009-09-18 22:42 ` Adam Beneschan
2009-09-19 12:41 ` Dirk Herrmann
2009-09-19 14:48   ` John B. Matthews
2009-09-20  8:15     ` Dirk Herrmann
2009-09-20 14:22       ` Robert A Duff
2009-09-20 18:55         ` Dirk Herrmann
2009-09-20 20:34           ` Simon Clubley
2009-09-23 20:46             ` Dirk Herrmann
2009-09-27 17:15               ` Simon Clubley
2009-09-27 19:22           ` sjw [this message]
2009-09-28 20:18             ` Dirk Herrmann
2009-09-28 18:37           ` Robert A Duff
2009-09-28 20:50             ` Dirk Herrmann
2009-09-20 15:18       ` John B. Matthews
2009-09-20 19:13         ` Dirk Herrmann
2009-09-20 20:09       ` tmoran
2009-09-21 17:24       ` Jeffrey R. Carter
2009-09-23 20:57         ` Dirk Herrmann
2009-09-23 22:28           ` Jeffrey R. Carter
2009-09-24  1:05             ` Adam Beneschan
2009-09-24  3:57               ` Jeffrey R. Carter
2009-09-25  8:47               ` Stuart
2009-09-25 20:41                 ` sjw
2009-09-25 21:58                   ` Jeffrey R. Carter
2009-09-28 13:40                   ` Stuart
2009-09-26 14:43                 ` Dirk Herrmann
2009-09-28 15:15                   ` Adam Beneschan
2009-09-26 14:31               ` Dirk Herrmann
2009-09-19 18:38   ` tmoran
2009-09-20  8:22 ` sjw
replies disabled

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