comp.lang.ada
 help / color / mirror / Atom feed
From: agate!dog.ee.lbl.gov!network.ucsd.edu!munnari.oz.au!csis!dubhe.anu.edu.au !newshost.anu.edu.au!csc.canberra.edu.au!lobo!karen@ucbvax.Berkeley.EDU  (Karen George)
Subject: Ceiling function in Ada
Date: 6 Apr 93 12:50:43 GMT	[thread overview]
Message-ID: <karen.734100643@lobo> (raw)

I'm a new user of Ada.  

My immediate problem is to implement the 
ceiling function - also called the next integer function.
I.e., for x a float, 1.0 < x <= 2.0, ceil(x) returns 2, etc.

My "real" problem is how to obtain only the integer part of the
floating point number.  In Pascal, and other languages, one can 
use a truncate function or coerce x to an integer which truncates
the fractional part. 

But, in Ada, coercion to integer actually rounds (so says the 
documentation) so how does one truncate a float in Ada?

Please don't bother suggesting adding 0.5 to x.  Not only is 
Integer(1.5) implementation dependant (so says the
documentation), but it is of no value anyway.  If Integer(1.5)
returns 2, then it's wrong for the ceiling function and I have
no means of determining that.  If it returns 1, then my function is
still implementation dependant and therefore not portable.

Thanks 

--
Karen George 				Email: 	karen@lobo.canberra.edu.au
Information Sciences and Engineering	Phone: 	+61 6 201 2430
University of Canberra,	AUSTRALIA 	FAX:	+61 6 201 5227
--
email: karen@ise.canberra.edu.au
       karen@lobo.canberra.edu.au
       karen@abel.anu.edu.au

             reply	other threads:[~1993-04-06 12:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-04-06 12:50 agate!dog.ee.lbl.gov!network.ucsd.edu!munnari.oz.au!csis!dubhe.anu.edu.au [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-04-06 19:47 Ceiling function in Ada Michael Feldman
1993-04-07 12:55 Tucker Taft
1993-04-10  8:03 pipex!bnr.co.uk!demon!cix.compulink.co.uk!sjwright
replies disabled

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