From: "DuckE" <nospam_steved94@home.com>
Subject: Re: Naturals and discrete types
Date: Fri, 02 Nov 2001 03:05:08 GMT
Date: 2001-11-02T03:05:08+00:00 [thread overview]
Message-ID: <E3oE7.5759$Tb.3031876@news1.sttln1.wa.home.com> (raw)
In-Reply-To: 8NkE7.221689$K6.106569186@news2
One other point (especially if you're coming from C). When you convert a
floating point value to an integer value using Integer( value ), Ada rounds,
it does not trucate.
Example:
WITH Ada.Integer_Text_Io;
WITH Ada.Text_Io;
PROCEDURE Conversions IS
BEGIN
Ada.Text_Io.Put( "Integer(3.4) = " );
Ada.Integer_Text_Io.Put( Integer( 3.4 ), 2 );
Ada.Text_Io.New_Line;
Ada.Text_Io.Put( "Integer(3.6) = " );
Ada.Integer_Text_Io.Put( Integer( 3.6 ), 2 );
Ada.Text_Io.New_Line;
END Conversions;
Output:
Integer(3.4) = 3
Integer(3.6) = 4
If you need to trucate, you can use Integer( Float'Truncation( value ) )
SteveD
> Everything is so damn simple isnt it? ;->
>
> And I remember covering this subject early on in my textbook.
> I'm a typical greenhorn I guess, making everything more complicated than
> it has to be.
>
> Thanks for your patience.
>
> Clueless
> chris@dont.spam.me
next prev parent reply other threads:[~2001-11-02 3:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-01 23:06 Naturals and discrete types Beard, Frank
2001-11-01 23:20 ` Clueless
2001-11-02 3:05 ` DuckE [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-11-01 22:05 Clueless
2001-11-01 22:35 ` Matthew Heaney
2001-11-01 22:59 ` Clueless
2001-11-02 15:05 ` Marin David Condic
2001-11-02 17:24 ` Ted Dennison
2001-11-02 18:19 ` Preben Randhol
2001-11-02 18:51 ` Marin David Condic
2001-11-03 18:01 ` Nick Roberts
2001-11-04 4:18 ` tmoran
2001-11-05 15:29 ` Marin David Condic
2001-11-04 11:39 ` Preben Randhol
2001-11-05 2:01 ` Clueless
2001-11-05 2:37 ` Larry Kilgallen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox