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,9a4dadd62f24335b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-02-10 15:53:12 PST Path: swrinde!howland.reston.ans.net!news.sprintlink.net!news.clark.net!NewsWatcher!user From: hirasuna@acm.org (Michael Hirasuna) Newsgroups: comp.lang.ada Subject: Re: floats to integers? Date: Fri, 10 Feb 1995 18:54:42 -0500 Organization: Clark Internet Services, Inc. Message-ID: References: <3hgfv9$468@mother.usf.edu> NNTP-Posting-Host: hirasuna.clark.net Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: 1995-02-10T18:54:42-05:00 List-Id: In article <3hgfv9$468@mother.usf.edu>, gahda@wusffm.wusf.usf.edu (Ghada ) wrote: > I'm new with Ada and I need to finish this assignment where I have to > turn a float into an integer (i.e. 2.89 to 2) any answers from you > gurus out there? Since you are new to Ada, I assume that this is not a trick question and give you the simple answer. Any numeric type can be explicitly type converted to any other numeric type. If A is a floating point variable, Integer (A) will yield an integer value. When converting a real type to an integer type Ada will round. Therefore, for your example, the type converting 2.89 will yield 3. Here is a question that you might ask a real Ada "guru" (we prefer the term "language lawyer"): Is there a portable way to define a truncation function in Ada 83, which rounds a floating point number down to the nearest integer? -- Michael Hirasuna | hirasuna@acm.org