comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin D. Condic" <mcondic-nospam@quadruscorp.com>
Subject: Re: Conversions
Date: 2000/03/16
Date: 2000-03-16T11:55:42+00:00	[thread overview]
Message-ID: <38D0F5CC.95F0F9B7@quadruscorp.com> (raw)
In-Reply-To: 38D0A673.EED850FD@student.ecu.edu.au

Karlene Johnson wrote:
> 
> I am trying to convert an Float number to an Integer number, after a
> calculation with 2 Float numbers.  Any suggesions on how to convert??

X  : Float := 1.234 ;
Y  : Integer := 0 ;
....

Y := Integer (X) ; -- Y should now contain the value "1"

There are a number of ways of handling truncation & rounding, but this
is the plain vanilla way to do it. The type name acts as a function to
perform the conversion. However, it only works with "compatible" types.
(You can't for example, convert a String to a Float this way.)

MDC
-- 
=============================================================
Marin David Condic   - Quadrus Corporation -   1.800.555.3393
1015-116 Atlantic Boulevard, Atlantic Beach, FL 32233
http://www.quadruscorp.com/
m c o n d i c @ q u a d r u s c o r p . c o m

***PLEASE REMOVE THE "-NOSPAM" PART OF MY RETURN ADDRESS***

Visit my web site at:  http://www.mcondic.com/

"Because that's where they keep the money."
    --  Willie Sutton when asked why he robbed banks. 
=============================================================




  reply	other threads:[~2000-03-16  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-16  0:00 Conversions Karlene Johnson
2000-03-16  0:00 ` Marin D. Condic [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-10-07 12:40 Ada.Directories.Base_Name and dot files 
2009-10-08  9:39 ` Stephen Leake
2009-10-08  9:58   ` 
2009-10-26 19:27     ` Conversions Bruno
2009-10-26 20:09       ` Conversions Jeffrey R. Carter
2009-10-26 20:19       ` Conversions Adam Beneschan
replies disabled

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