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: a07f3367d7,d2a3144038a5a80e X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!bigfeed3.bellsouth.net!news.bellsouth.net!border2.nntp.dca.giganews.com!nntp.giganews.com!backlog2.nntp.dca.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Sat, 13 Jun 2009 11:13:12 -0500 Newsgroups: comp.lang.ada Followup-To: comp.lang.ada From: Robert Matthews Subject: Re: Question on types conversions - operations Date: Sat, 13 Jun 2009 17:13:35 +0100 References: <4a33cb0b$0$2848$ba620e4c@news.skynet.be> User-Agent: KNode/0.99.01 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7Bit Message-ID: X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-FpC4qbbD0I/jLTa9XTJhzg2ZHvT8bZykmGkGeRtTq/b42zrQFHu2BqC+IIkihBgYde7y1W9EHvc3fvp!ZwENBEP2ACl3cNffKjw4TpMzdkDS6HT4bJAuLt7UD39RGIFh3fzzS+CYMuuSohZcKJTVYY50lG8z!8ooHOpHZugxrZ4noyg/XXG7w X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.39 Xref: g2news2.google.com comp.lang.ada:6456 Date: 2009-06-13T17:13:35+01:00 List-Id: Olivier Scalbert wrote: > Hello, > > I have the following three types: > type Length is new Float; > type Time is new Float; > type Speed is new Float; > > Suppose I need to compute a speed given a length and a time. > > L: Length := 100.0; > T: Time := 10.0; > S: Speed; > > How to do that ? > > With S := Speed(Float(L) / Float(T)) ? Mmmm ... not nice. > > With S := Speed(L / Length(T)), I am also not satisfy as I convert a > time in Length ... > > I am sure you have better ideas ! > > Good weekend, > > Olivier For some software with a LOT of maths, I used: type Working_Real_Type is digits 16; (which was big enough for the VAX target). I would convert the various values (typed in a similar way to your Length, Time etc) to Working_Real_Type before using them in the equations. It was certainly not ideal but it seemed a reasonable compromise between type safety and the maths. Robert