comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Anouncement: OpenGL Binding w/ Ada-2012.
Date: Thu, 25 Oct 2012 18:46:47 -0700 (PDT)
Date: 2012-10-25T18:46:47-07:00	[thread overview]
Message-ID: <4e2d0db0-a0f0-499e-8e86-8a82aa3a949c@googlegroups.com> (raw)
In-Reply-To: <a12e5f96-388f-4261-aa4c-c4fdfae24d56@googlegroups.com>

On Thursday, October 25, 2012 4:22:43 PM UTC-6, Quentin Ochem wrote:
> > 
> > Can it? I'd have to take a look at the way Ada's ranges for floats work again to tell. IIRC it's [Min_val..Max_Val), if that is the case there is one important value which is not precluded from the parameter of the new specification: 0.0.
> 
> Arf - you're entirely right on this, looked at this aspect to quickly.

Yep, I've done that myself.

> The alternative is to either use a definition starting at the first value after 0.0:
> 
> subtype Positive_Float is Float range Float'Succ (0.0) .. Float'Last;

True, that's a good one. Though I'm wondering if the Succ will be the next normal value, or the next [possibly denormalized] value... I'll have to look into that later, perhaps when dealing w/ OpenGL's 10-, 11-, and 16-bit floating point numbers.

> which admittedly is less readable. Alternatively, an Ada 2012 static predicate would work just as well:
> subtype Positive_Float is Float 
> with Static_Predicate => Positive_Float > 0.0;
> 
> Given the amount of places where this notion of positive float is used, it's interesting to try out either of these two forms.

Agreed. It would be interesting to see if the two methods are a: equivalent, and b: if there's any performance difference between the two.

Intuitively you would think they were the same, but there may be subtle differences... such as if the subtype's parent is an IEEE float, +Inf would be a valid value for the predicate but an invalid value for the range {because we use subtype Safe_Float is Float'Range to weed out all the non-numeric representations the Succ(0.0)..Float'Last range is a strict subset of Float'Range it too would exclude +Inf whereas a subtype w/ only the greater-than-zero predicate might not.}



  reply	other threads:[~2012-10-26  1:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-18 17:16 Anouncement: OpenGL Binding w/ Ada-2012 Shark8
2012-10-24  3:38 ` joel.s.williamson
2012-10-24 20:33   ` Shark8
2012-10-24 16:32 ` Quentin Ochem
2012-10-24 20:40   ` Shark8
2012-10-25 22:22     ` Quentin Ochem
2012-10-26  1:46       ` Shark8 [this message]
2012-10-26 13:50 ` Yannick Duchêne (Hibou57)
2012-10-27  1:56   ` Shark8
replies disabled

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