* Range excluding 0.0 @ 2009-08-29 12:50 vlc 2009-08-29 13:12 ` Dmitry A. Kazakov ` (2 more replies) 0 siblings, 3 replies; 17+ messages in thread From: vlc @ 2009-08-29 12:50 UTC (permalink / raw) Hi *, I would like to declare a subtype of Float which ranges from 0.0 (excluded) to Float'Last. Is there a way to exclude the 0.0 from the range? Thanks a lot in avcance! ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-29 12:50 Range excluding 0.0 vlc @ 2009-08-29 13:12 ` Dmitry A. Kazakov 2009-08-29 13:46 ` John B. Matthews 2009-08-29 17:47 ` Charles H. Sampson 2 siblings, 0 replies; 17+ messages in thread From: Dmitry A. Kazakov @ 2009-08-29 13:12 UTC (permalink / raw) On Sat, 29 Aug 2009 05:50:38 -0700 (PDT), vlc wrote: > I would like to declare a subtype of Float which ranges from 0.0 > (excluded) to Float'Last. Is there a way to exclude the 0.0 from the > range? subtype Positve_Float is Float range Float'Succ (0.0)..Float'Last; When the machine is IEEE, this also excludes IEEE ideals between zero and machine epsilon as well as infinities. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-29 12:50 Range excluding 0.0 vlc 2009-08-29 13:12 ` Dmitry A. Kazakov @ 2009-08-29 13:46 ` John B. Matthews 2009-08-29 17:10 ` vlc 2009-08-29 17:47 ` Charles H. Sampson 2 siblings, 1 reply; 17+ messages in thread From: John B. Matthews @ 2009-08-29 13:46 UTC (permalink / raw) In article <6f1ce89e-7889-4d58-b0f8-1945727f5149@f33g2000vbm.googlegroups.com>, vlc <just.another.spam.account@googlemail.com> wrote: > I would like to declare a subtype of Float which ranges from 0.0 > (excluded) to Float'Last. Is there a way to exclude the 0.0 from the > range? Perhaps something like this: subtype Non_Zero is Float range Float'Succ(0.0) .. Float'Last; The range on my implementation is 1.40130E-45 to 3.40282E+38. -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-29 13:46 ` John B. Matthews @ 2009-08-29 17:10 ` vlc 0 siblings, 0 replies; 17+ messages in thread From: vlc @ 2009-08-29 17:10 UTC (permalink / raw) That should work. Thanks a lot! ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-29 12:50 Range excluding 0.0 vlc 2009-08-29 13:12 ` Dmitry A. Kazakov 2009-08-29 13:46 ` John B. Matthews @ 2009-08-29 17:47 ` Charles H. Sampson 2009-08-29 19:28 ` Robert A Duff ` (2 more replies) 2 siblings, 3 replies; 17+ messages in thread From: Charles H. Sampson @ 2009-08-29 17:47 UTC (permalink / raw) vlc <just.another.spam.account@googlemail.com> wrote: > > I would like to declare a subtype of Float which ranges from 0.0 > (excluded) to Float'Last. Is there a way to exclude the 0.0 from the > range? You've already got the answer you need, but your question brings up another that I've recently been puzzled about. Why doesn't Ada allow all four flavors of ranges commonly used by mathematicians (and others): individually including or excluding the endpoints? I've been around Ada since close to the beginning and I don't recall that this was ever discussed. At the same time, I have this vague memory that one of the candidate languages might have had it, but I can't remember which one it might have been. This is not just theoretical musing. I currently work in the world of compasses, so a range of the form [0.0 .. 360.0) is quite natural. (That notation is neither mathematical nor Ada. I hope its meaning is clear.) Charlie -- All the world's a stage, and most of us are desperately unrehearsed. Sean O'Casey ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-29 17:47 ` Charles H. Sampson @ 2009-08-29 19:28 ` Robert A Duff 2009-08-30 18:34 ` Charles H. Sampson 2009-08-29 20:51 ` John B. Matthews 2009-08-30 7:38 ` Dmitry A. Kazakov 2 siblings, 1 reply; 17+ messages in thread From: Robert A Duff @ 2009-08-29 19:28 UTC (permalink / raw) csampson@inetworld.net (Charles H. Sampson) writes: > vlc <just.another.spam.account@googlemail.com> wrote: >> >> I would like to declare a subtype of Float which ranges from 0.0 >> (excluded) to Float'Last. Is there a way to exclude the 0.0 from the >> range? > > You've already got the answer you need, but your question brings up > another that I've recently been puzzled about. Why doesn't Ada allow > all four flavors of ranges commonly used by mathematicians (and others): > individually including or excluding the endpoints? For that matter, why doesn't Ada allow arbitrary subsets? For example, "an integer in the range -1_000_000 to 1_000_000, except 0 is not allowed". Or, "an integer for which Is_Good returns True". ARG is thinking about adding type invariants and/or user-defined constraints, which could express such things. >...I've been around Ada > since close to the beginning and I don't recall that this was ever > discussed. At the same time, I have this vague memory that one of the > candidate languages might have had it, but I can't remember which one it > might have been. > > This is not just theoretical musing. I currently work in the world > of compasses, so a range of the form [0.0 .. 360.0) is quite natural. > (That notation is neither mathematical nor Ada. I hope its meaning is > clear.) It's certainly not Ada, but why do you say it's not mathematical? I find it ugly, but I've certainly seen in maths textbooks. Ignoring the ugly syntax, the concept seems quite useful. - Bob ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-29 19:28 ` Robert A Duff @ 2009-08-30 18:34 ` Charles H. Sampson 0 siblings, 0 replies; 17+ messages in thread From: Charles H. Sampson @ 2009-08-30 18:34 UTC (permalink / raw) Robert A Duff <bobduff@shell01.TheWorld.com> wrote: > > csampson@inetworld.net (me) writes: > > > This is not just theoretical musing. I currently work in the world > > of compasses, so a range of the form [0.0 .. 360.0) is quite natural. > > (That notation is neither mathematical nor Ada. I hope its meaning is > > clear.) > > It's certainly not Ada, but why do you say it's not mathematical? > I find it ugly, but I've certainly seen in maths textbooks. > Ignoring the ugly syntax, the concept seems quite useful. > Things might have changed since the days when I read math texts by the bushel, but in those days the notation would have been [0, 360). But, for the purpose of this sub-thread, who cares? As long as what I meant is understandable, I'm happy. Charlie -- All the world's a stage, and most of us are desperately unrehearsed. Sean O'Casey ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-29 17:47 ` Charles H. Sampson 2009-08-29 19:28 ` Robert A Duff @ 2009-08-29 20:51 ` John B. Matthews 2009-08-30 7:34 ` Dmitry A. Kazakov 2009-08-30 7:38 ` Dmitry A. Kazakov 2 siblings, 1 reply; 17+ messages in thread From: John B. Matthews @ 2009-08-29 20:51 UTC (permalink / raw) In article <1j57hiw.vmezw81qexbi6N%csampson@inetworld.net>, csampson@inetworld.net (Charles H. Sampson) wrote: [...] > This is not just theoretical musing. I currently work in the > world of compasses, so a range of the form [0.0 .. 360.0) is quite > natural. (That notation is neither mathematical nor Ada. I hope its > meaning is clear.) I'd be torn between these, but wrapping around the right end would be a problem with either: subtype Heading is Float range 0.0 .. 360.0; subtype Heading is Float range 0.0 .. Float'Pred(360.0); If the range were intended to model a craft's heading (perhaps in degrees, minutes & seconds), I'd be tempted to consider a modular type: type Heading is mod 360 * 60 * 60; This might make a relative change in heading easier to implement. -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-29 20:51 ` John B. Matthews @ 2009-08-30 7:34 ` Dmitry A. Kazakov [not found] ` <7_KdnXzM3cepeAfXnZ2dnUVZ_vidnZ2d@earthlink.com> 0 siblings, 1 reply; 17+ messages in thread From: Dmitry A. Kazakov @ 2009-08-30 7:34 UTC (permalink / raw) On Sat, 29 Aug 2009 16:51:56 -0400, John B. Matthews wrote: > In article <1j57hiw.vmezw81qexbi6N%csampson@inetworld.net>, > csampson@inetworld.net (Charles H. Sampson) wrote: > > [...] >> This is not just theoretical musing. I currently work in the >> world of compasses, so a range of the form [0.0 .. 360.0) is quite >> natural. (That notation is neither mathematical nor Ada. I hope its >> meaning is clear.) > > I'd be torn between these, but wrapping around the right end would be a > problem with either: > > subtype Heading is Float range 0.0 .. 360.0; > subtype Heading is Float range 0.0 .. Float'Pred(360.0); > > If the range were intended to model a craft's heading (perhaps in > degrees, minutes & seconds), I'd be tempted to consider a modular type: Still using non-metric units, guys? (:-)) > type Heading is mod 360 * 60 * 60; > > This might make a relative change in heading easier to implement. Second : constant := 1.0 / (60.0 * 60.0); type Heading is delta Second range 0.0..360.0 - Second; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <7_KdnXzM3cepeAfXnZ2dnUVZ_vidnZ2d@earthlink.com>]
* Re: Range excluding 0.0 [not found] ` <7_KdnXzM3cepeAfXnZ2dnUVZ_vidnZ2d@earthlink.com> @ 2009-08-31 7:37 ` Dmitry A. Kazakov 2009-08-31 13:58 ` John B. Matthews 0 siblings, 1 reply; 17+ messages in thread From: Dmitry A. Kazakov @ 2009-08-31 7:37 UTC (permalink / raw) On Sun, 30 Aug 2009 13:46:49 -0700, Dennis Lee Bieber wrote: > On Sun, 30 Aug 2009 09:34:06 +0200, "Dmitry A. Kazakov" > <mailbox@dmitry-kazakov.de> declaimed the following in comp.lang.ada: >> >> Still using non-metric units, guys? (:-)) >> > You have compasses marked in radians? I'd hate to consider working > out what "bear left 2/3radian from current heading" means... <G> I thought these were in rhumbs. > Grad notation, OTOH, might be usable... ... another orbiter loss due to metric mishap? Helps stocking up the budget... (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-31 7:37 ` Dmitry A. Kazakov @ 2009-08-31 13:58 ` John B. Matthews 2009-08-31 18:49 ` Dmitry A. Kazakov [not found] ` <iradnblskszGlgHXnZ2dnUVZ_oSdnZ2d@earthlink.com> 0 siblings, 2 replies; 17+ messages in thread From: John B. Matthews @ 2009-08-31 13:58 UTC (permalink / raw) In article <14d916mebuseu$.59fjaud14sw7.dlg@40tude.net>, "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote: > On Sun, 30 Aug 2009 13:46:49 -0700, Dennis Lee Bieber wrote: > > > On Sun, 30 Aug 2009 09:34:06 +0200, "Dmitry A. Kazakov" > > <mailbox@dmitry-kazakov.de> declaimed the following in comp.lang.ada: > >> > >> Still using non-metric units, guys? (:-)) > >> > > You have compasses marked in radians? I'd hate to consider working > > out what "bear left 2/3radian from current heading" means... <G> > > I thought these were in rhumbs. > > > Grad notation, OTOH, might be usable... > > ... another orbiter loss due to metric mishap? Helps stocking up the > budget... (:-)) My present velocity, in the solar reference frame, is just under 2.7 megafurlongs/fortnight. How do I convert left and right to metric when I cross the equator, bearing -pi/2? :-) -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-31 13:58 ` John B. Matthews @ 2009-08-31 18:49 ` Dmitry A. Kazakov 2009-09-01 18:10 ` Keith Thompson [not found] ` <iradnblskszGlgHXnZ2dnUVZ_oSdnZ2d@earthlink.com> 1 sibling, 1 reply; 17+ messages in thread From: Dmitry A. Kazakov @ 2009-08-31 18:49 UTC (permalink / raw) On Mon, 31 Aug 2009 09:58:05 -0400, John B. Matthews wrote: > In article <14d916mebuseu$.59fjaud14sw7.dlg@40tude.net>, > "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote: > >> On Sun, 30 Aug 2009 13:46:49 -0700, Dennis Lee Bieber wrote: >> >>> On Sun, 30 Aug 2009 09:34:06 +0200, "Dmitry A. Kazakov" >>> <mailbox@dmitry-kazakov.de> declaimed the following in comp.lang.ada: >>>> >>>> Still using non-metric units, guys? (:-)) >>>> >>> You have compasses marked in radians? I'd hate to consider working >>> out what "bear left 2/3radian from current heading" means... <G> >> >> I thought these were in rhumbs. >> >>> Grad notation, OTOH, might be usable... >> >> ... another orbiter loss due to metric mishap? Helps stocking up the >> budget... (:-)) > > My present velocity, in the solar reference frame, is just under 2.7 > megafurlongs/fortnight. How do I convert left and right to metric when I > cross the equator, bearing -pi/2? :-) You need a Jacob's staff for this... (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-31 18:49 ` Dmitry A. Kazakov @ 2009-09-01 18:10 ` Keith Thompson 0 siblings, 0 replies; 17+ messages in thread From: Keith Thompson @ 2009-09-01 18:10 UTC (permalink / raw) "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes: > On Mon, 31 Aug 2009 09:58:05 -0400, John B. Matthews wrote: >> In article <14d916mebuseu$.59fjaud14sw7.dlg@40tude.net>, >> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote: >>> On Sun, 30 Aug 2009 13:46:49 -0700, Dennis Lee Bieber wrote: >>>> On Sun, 30 Aug 2009 09:34:06 +0200, "Dmitry A. Kazakov" >>>> <mailbox@dmitry-kazakov.de> declaimed the following in comp.lang.ada: >>>>> Still using non-metric units, guys? (:-)) >>>>> >>>> You have compasses marked in radians? I'd hate to consider working >>>> out what "bear left 2/3radian from current heading" means... <G> >>> >>> I thought these were in rhumbs. >>> >>>> Grad notation, OTOH, might be usable... >>> >>> ... another orbiter loss due to metric mishap? Helps stocking up the >>> budget... (:-)) >> >> My present velocity, in the solar reference frame, is just under 2.7 >> megafurlongs/fortnight. How do I convert left and right to metric when I >> cross the equator, bearing -pi/2? :-) > > You need a Jacob's staff for this... (:-)) I'd rather have a Jacob's Ladder. Not much good for navigation, but a lot more fun. -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister" ^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <iradnblskszGlgHXnZ2dnUVZ_oSdnZ2d@earthlink.com>]
* Re: Range excluding 0.0 [not found] ` <iradnblskszGlgHXnZ2dnUVZ_oSdnZ2d@earthlink.com> @ 2009-09-01 0:36 ` John B. Matthews 0 siblings, 0 replies; 17+ messages in thread From: John B. Matthews @ 2009-09-01 0:36 UTC (permalink / raw) In article <iradnblskszGlgHXnZ2dnUVZ_oSdnZ2d@earthlink.com>, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote: > On Mon, 31 Aug 2009 09:58:05 -0400, "John B. Matthews" > <nospam@nospam.invalid> declaimed the following in comp.lang.ada: > > > My present velocity, in the solar reference frame, is just under 2.7 > > megafurlongs/fortnight. How do I convert left and right to metric when I > > cross the equator, bearing -pi/2? :-) > > How many slugs of thrust? Oh, I'm on foot; the force is some large number of poundals, I imagine, as I tend to plod. I thought slugs, like scruples, measured mass. My claim above is based on rotational velocity; I completely ignored the larger component of velocity tangent to the Earth's orbit. Perhaps I am dizzy. :-) -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-29 17:47 ` Charles H. Sampson 2009-08-29 19:28 ` Robert A Duff 2009-08-29 20:51 ` John B. Matthews @ 2009-08-30 7:38 ` Dmitry A. Kazakov 2009-08-30 18:34 ` Charles H. Sampson 2 siblings, 1 reply; 17+ messages in thread From: Dmitry A. Kazakov @ 2009-08-30 7:38 UTC (permalink / raw) On Sat, 29 Aug 2009 10:47:17 -0700, Charles H. Sampson wrote: > This is not just theoretical musing. I currently work in the world > of compasses, so a range of the form [0.0 .. 360.0) is quite natural. > (That notation is neither mathematical nor Ada. I hope its meaning is > clear.) That is not range, the type would be not of real numbers. For example: 340.0 + 25.0 = 5.0 etc -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-30 7:38 ` Dmitry A. Kazakov @ 2009-08-30 18:34 ` Charles H. Sampson 2009-08-30 20:43 ` Dmitry A. Kazakov 0 siblings, 1 reply; 17+ messages in thread From: Charles H. Sampson @ 2009-08-30 18:34 UTC (permalink / raw) Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote: > On Sat, 29 Aug 2009 10:47:17 -0700, I wrote: > > > This is not just theoretical musing. I currently work in the world > > of compasses, so a range of the form [0.0 .. 360.0) is quite natural. > > (That notation is neither mathematical nor Ada. I hope its meaning is > > clear.) > > That is not range, the type would be not of real numbers. For example: > > 340.0 + 25.0 = 5.0 > Right, but that's not unusual. Of the predefined types of Ada, only modular and enumeration types are closed under their predefined operations. What I want is a way to express the set of real numbers (in the Ada sense) that an object of the type can legally hold. We already write the code to prevent a stored value of 360.0. What I want is a constraint error just in case we foul up. To be frank, I had forgotten that we can achieve the effect by using Pred or some other attributes, even though I've done that in another context. But my question essentially was, why weren't we given a notation to do it directly and easily? Charlie -- All the world's a stage, and most of us are desperately unrehearsed. Sean O'Casey ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Range excluding 0.0 2009-08-30 18:34 ` Charles H. Sampson @ 2009-08-30 20:43 ` Dmitry A. Kazakov 0 siblings, 0 replies; 17+ messages in thread From: Dmitry A. Kazakov @ 2009-08-30 20:43 UTC (permalink / raw) On Sun, 30 Aug 2009 11:34:00 -0700, Charles H. Sampson wrote: > Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote: > >> On Sat, 29 Aug 2009 10:47:17 -0700, I wrote: >> >>> This is not just theoretical musing. I currently work in the world >>> of compasses, so a range of the form [0.0 .. 360.0) is quite natural. >>> (That notation is neither mathematical nor Ada. I hope its meaning is >>> clear.) >> >> That is not range, the type would be not of real numbers. For example: >> >> 340.0 + 25.0 = 5.0 >> > Right, but that's not unusual. Of the predefined types of Ada, > only modular and enumeration types are closed under their predefined > operations. Float is also closed when the underlying machine type is IEEE. > What I want is a way to express the set of real numbers (in the Ada > sense) that an object of the type can legally hold. We already write > the code to prevent a stored value of 360.0. What I want is a > constraint error just in case we foul up. These are two different issues: 1. Ranges as first-class objects with operations on them. This includes intervals and interval operations. 2. Special kinds of arithmetic saturated, wrapped etc. > To be frank, I had forgotten that we can achieve the effect by > using Pred or some other attributes, even though I've done that in > another context. Actually T'Pred and T'Succ are poor implementations because they are machine-dependent and not directly (or clearly) derived from "digits" and "delta". > But my question essentially was, why weren't we given > a notation to do it directly and easily? Because it is too complex to do. Here I mean a built-in language feature in a patchwork of chaotic changes. Complexity is also in driving attention of ARG members to this concrete patch from a rapidly growing pile... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2009-09-01 18:10 UTC | newest] Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-08-29 12:50 Range excluding 0.0 vlc 2009-08-29 13:12 ` Dmitry A. Kazakov 2009-08-29 13:46 ` John B. Matthews 2009-08-29 17:10 ` vlc 2009-08-29 17:47 ` Charles H. Sampson 2009-08-29 19:28 ` Robert A Duff 2009-08-30 18:34 ` Charles H. Sampson 2009-08-29 20:51 ` John B. Matthews 2009-08-30 7:34 ` Dmitry A. Kazakov [not found] ` <7_KdnXzM3cepeAfXnZ2dnUVZ_vidnZ2d@earthlink.com> 2009-08-31 7:37 ` Dmitry A. Kazakov 2009-08-31 13:58 ` John B. Matthews 2009-08-31 18:49 ` Dmitry A. Kazakov 2009-09-01 18:10 ` Keith Thompson [not found] ` <iradnblskszGlgHXnZ2dnUVZ_oSdnZ2d@earthlink.com> 2009-09-01 0:36 ` John B. Matthews 2009-08-30 7:38 ` Dmitry A. Kazakov 2009-08-30 18:34 ` Charles H. Sampson 2009-08-30 20:43 ` Dmitry A. Kazakov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox