From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c1bdceb867926fdb X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Interfacing Ada with C Date: Fri, 06 Aug 2010 21:26:18 +0100 Organization: A noiseless patient Spider Message-ID: References: <143ef70b-7e74-426b-a621-a5fd157849be@x21g2000yqa.googlegroups.com> <06eb8f61-2a0c-4dda-93f3-8414d32b6e4f@f20g2000pro.googlegroups.com> <87pqxwrwtz.fsf@hugsarin.sparre-andersen.dk> <1t7qv7gn9gugg$.alpj3tkmkw1y$.dlg@40tude.net> <1hpn479yuv29e.1ryblciqi0msh.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Fri, 6 Aug 2010 20:26:19 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="KCXegvZb5vh43D+f3BR6Ew"; logging-data="27816"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jAnLUsUX6zM09SOUrEkVw/MzkPpkXmbM=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) Cancel-Lock: sha1:0CePscAwQ4Nj5op4UHw4MltPWK8= sha1:0Sbq2uhjK8Lf/a3me9lI2BhS3ho= Xref: g2news1.google.com comp.lang.ada:12917 Date: 2010-08-06T21:26:18+01:00 List-Id: "Dmitry A. Kazakov" writes: > On Fri, 06 Aug 2010 17:49:14 +0100, Simon Wright wrote: > >> "Dmitry A. Kazakov" writes: >> >>> On Fri, 06 Aug 2010 10:04:24 +0200, Jacob Sparre Andersen wrote: >>> >>>> Ada novice wrote: >>>> >>>>> Can we change the subtype to Long_Long_Float? This will be of 18 >>>>> precision digits [...] >>>> >>>> That's not guaranteed. If you want 18 digits, you should declare the >>>> type (My_Float?) as: >>>> >>>> type My_Float is digits 18; >>> >>> Further, practically you should never use subtype in the form >>> >>> subtype My_Float is Long_Float; >>> >>> except for special cases like: >>> >>> subtype Non_IEEE_Float is Long_Float range Long_Float'Range; >>> >>> or >>> >>> subtype Non_Negative_Float is Long_Float range 0.0..Long_Float'Last; >> >> Depends what you mean by "practically". >> >> The thought process was, "I'm going to be writing a set of demo cases >> which should work for arbitrary floating-point types, I'll call the type >> My_Float. Shall I use type My_Float is new ... or subtype My_Float is >> ...? Doesn't really matter, go for subtype." > > I am not sure what do you mean. If the code meant to be used with any type, > then it should be generic (My_Float is digits <>). If the code is to work > with some yet unknown type (to be determined later) then it should be > My_Float is new Long_Float. That would protect me from mixing Long_Float > and My_Float. You're clearly right for serious code (in this case, for serious unit tests which I may well make generic). But this wasn't a serious test, it was an exploratory hack. Perhaps I shouldn't have let it out into the wild without a bit more polishing. I do feel that writing a demo like this one as a set of generics instantiated for various floating types would probably have obscured the point.