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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c9eb2aff6d161576 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-15 17:30:55 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!feed2.news.rcn.net!rcn!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3C92A045.78ABDF75@acm.org> From: Jeffrey Carter X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Floats together with Integers References: <3c929b72$0$7414@motown.iinet.net.au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sat, 16 Mar 2002 01:30:57 GMT NNTP-Posting-Host: 209.86.207.189 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1016242257 209.86.207.189 (Fri, 15 Mar 2002 17:30:57 PST) NNTP-Posting-Date: Fri, 15 Mar 2002 17:30:57 PST Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Fri, 15 Mar 2002 17:30:54 PST (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:21313 Date: 2002-03-16T01:30:57+00:00 List-Id: Max Power wrote: > > Is there any possible way to have a float and an integer together in the same equation? > > i.e. > > Int1 := Integer > Int2 := Float > Sum := Float > > Int1 * Int2 = Sum > > If so, how can I make the equation work without errors, is there some > sort of syntax/function used to enable a sum to be calculated when both > a float and integer reside in the same equation? A subprogram must have actual parameters that match the types of its formal parameters. There is no predefined subprogram function "*" (Left : Integer; Right : Float) return ; in Ada. However, you can define your own if you want. Then, of course, you need to know how to implement it. Any numeric type may be converted to any other numeric type, subject to meeting the appropriate constraints; converting from a real type to an integer type results in rounding. So perhaps you want to write Float (Int1) * Int2 = Sum This converts Int1 to Float before multiplying the result and Int2, then compares the result of the multiplication to Sum using equality defined for Float. -- Jeff Carter "You tiny-brained wipers of other people's bottoms!" Monty Python & the Holy Grail