comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Question about ordinary fixed point types.
Date: Mon, 16 Aug 2010 00:08:19 +0200
Date: 2010-08-16T00:08:19+02:00	[thread overview]
Message-ID: <op.vhh2f5neule2fv@garhos> (raw)
In-Reply-To: 4c685fac$0$2373$4d3efbfe@news.sover.net

Hi Peter, nice to see you again,

Le Sun, 15 Aug 2010 23:43:43 +0200, Peter C. Chapin <chapinp@acm.org> a  
écrit:

> I have a need to work with ordinary fixed point types. I've read the in
> the reference manual about them (section 3.5.9, for example), and some
> other things. I still have a few questions. I thought I'd start with one
> here.
>
> Consider this example:
>
>
> type Angle_Type is delta 0.0005 range -3.1416 .. 3.1416;
> Angle : Angle_Type;
> ...
> Angle := Angle_Type'First;
> while Angle < Angle_Type'Last loop
>   -- Work with Angle here.
>   Angle := Angle + Angle_Type'Small;
> end loop;
OK.


> Aside from Angle_Type'Last does the loop above reliably visit every
> possible value of Angle_Type? By "reliably" I mean "has the desired
> effect on all possible correct Ada implementations." I guess my question
> is: does Angle + Angle_Type'Small always advance Angle to the next
> machine number in the type?
What do you mean with “to the next machine number in the type” ? That this  
may not advance in some case ?

> I'm using GNAT GPL 2010 and in the example above GNAT appears to be
> using 2**(-11) for Angle_Type'Small.
So a bit less than the desired 0.0005

If the matter is the precise exploration of a precise set of points in a  
range, I may have a silly suggestion (silly in some sense, while not so  
much in some others) : why not use an array of predefined points ? Here,  
you would have an array of 12566 points. Ok, this may seems a big array,  
some design for hight efficiency. But this would come with the benefit of  
an precise and may be adjustable point by point, set of points. The  
Quality of this set of point could be precisely evaluated and adjusted.  
This is relevant here, as any way, you will never get exact value, because  
as you noticed, the delta does not allow to exactly match the range.

What is the purpose of the exploration ? Sampling at normalized position  
or something of the like ?

I would be very interested to know more about the intended use. This will  
learn us a lot of things.


-- 
There is even better than a pragma Assert: a SPARK --# check.
--# check C and WhoKnowWhat and YouKnowWho;
--# assert Ada;
--  i.e. forget about previous premises which leads to conclusion
--  and start with new conclusion as premise.



  parent reply	other threads:[~2010-08-15 22:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-15 21:43 Question about ordinary fixed point types Peter C. Chapin
2010-08-15 21:55 ` Shark8
2010-08-16  0:46   ` Peter C. Chapin
2010-08-16  4:13     ` Jeffrey Carter
2010-08-16  8:57       ` Simon Wright
2010-08-15 22:08 ` Yannick Duchêne (Hibou57) [this message]
2010-08-16  1:03   ` Peter C. Chapin
2010-08-16  4:11     ` Jeffrey Carter
2010-08-16 10:03       ` Ludovic Brenta
2010-08-17 14:35         ` sjw
2010-08-17 15:51           ` Ludovic Brenta
2010-08-16 11:31       ` Peter C. Chapin
2010-08-16  9:23     ` Simon Wright
2010-08-16 15:47       ` Simon Wright
2010-08-17 14:37       ` sjw
2010-08-16 11:02 ` Stephen Leake
2010-08-16 11:29   ` Peter C. Chapin
2010-08-16 12:53     ` Dmitry A. Kazakov
2010-08-16 20:28       ` Peter C. Chapin
2010-08-16 20:58         ` Adam Beneschan
2010-08-16 13:01     ` Dmitry A. Kazakov
2010-08-16 14:28     ` Robert A Duff
2010-08-16 20:31       ` Peter C. Chapin
2010-08-16 23:01         ` Robert A Duff
2010-08-16 23:17           ` Peter C. Chapin
2010-08-17  0:56             ` Robert A Duff
2010-08-17  2:03     ` Stephen Leake
2010-08-20  1:21 ` Yannick Duchêne (Hibou57)
replies disabled

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