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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d57302f2954365e1 X-Google-Attributes: gid103376,public From: Mats Weber Subject: Re: Question about base types Date: 1997/02/07 Message-ID: <32FB5B4A.1B95@elca-matrix.ch>#1/1 X-Deja-AN: 215311649 references: content-type: text/plain; charset=us-ascii organization: ELCA Matrix SA mime-version: 1.0 reply-to: Mats.Weber@elca-matrix.ch newsgroups: comp.lang.ada x-mailer: Mozilla 3.01 (Macintosh; I; PPC) Date: 1997-02-07T00:00:00+00:00 List-Id: > << << type Real is digits 7 range 0.0 .. 1.0; > << << package Actual is new Example (Real =<< Real); > << << > << << The implementation of Op needs to be able to do calculations independent > << << of any range constraint on the actual parameter associated with the > << << formal parameter Real. So it does its calculations using Real'Base: > << << > << << function Op (Arg : Real) return Real is > << << Result : Real'Base := Arg + 27.0; > << > << This could fail (i.e. raise Constraint_Error), since 27.0 is not > << required to be in the range of Real'Base. But it will work on most > << machines because on reasonable implementations, floating point types are > << mapped to representations that the hardware can handle efficiently (e.g. > << IEEE). >> > > This is a little misleading. While it is true that, unlike the case in > Ada 83, where of course the base type of type Real must have a big range, > the definitions of Ada 95 DO allow a narrow range IF that is what the > hardware provides (I am assuming annex G is implemented). Since there are > no machines with floating point types with 7 digits of precision and a > range that does not include 27.0, nor could there ever be such machines, > to worry about this eventuality is as silly as worrying about the fact > that a legal Ada implementation could raise storage_Error for every > possible program. True. But if you know that you are going to need larger intermediate results, then I think it is wiser to declare type Real_Base is digits 7; subtype Real is Real_Base range 0.0 .. 1.0; than type Real is digits 7 range 0.0 .. 1.0;