comp.lang.ada
 help / color / mirror / Atom feed
From: hirasuna@acm.org (Michael Hirasuna)
Subject: Re: floats to integers?
Date: Fri, 10 Feb 1995 18:54:42 -0500
Date: 1995-02-10T18:54:42-05:00	[thread overview]
Message-ID: <hirasuna-1002951854420001@168.143.6.213> (raw)
In-Reply-To: 3hgfv9$468@mother.usf.edu

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



  reply	other threads:[~1995-02-10 23:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-02-10 19:48 floats to integers? Ghada 
1995-02-10 23:54 ` Michael Hirasuna [this message]
1995-02-11 10:06   ` John Howard
1995-02-11 14:51     ` Michael Hirasuna
     [not found] <3i2gbu$56r@sanson.dit.upm.es>
     [not found] ` <3ie7je$dd9@newsbf02.news.aol.com>
1995-02-25 14:21   ` Michael Hirasuna
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox