comp.lang.ada
 help / color / mirror / Atom feed
From: jsa@organon.com (Jon S Anthony)
Subject: Re: Integer truncation and other recipes
Date: 1996/05/23
Date: 1996-05-23T00:00:00+00:00	[thread overview]
Message-ID: <JSA.96May22221027@organon.com> (raw)
In-Reply-To: 4nv3tmINNql5@oasys.dt.navy.mil


In article <4nv3tmINNql5@oasys.dt.navy.mil> shedlars@oasys.dt.navy.mil (Paul Shedlarski) writes:

> In Ada, how do you convert from a real to an integer by truncation?
> That is, how would you convert a value such as 1.9 to 1?

Per the ARM (found using the HTML version so I could cut and paste
for demonstration...):

Go to index and find entry:

  Truncation attribute 
         A.5.3(42), K(248) 

Go to A.5.3(42) and find:

  (42)
      S'Truncation 
  	  S'Truncation denotes a function with the following specification: 
  
  (43)
  	  function S'Truncation (X : T)
  	    return T
  
  (44)
  	     The function yields the value Ceiling(X) when X is
  	     negative, and Floor(X) otherwise. A zero result has
  	     the sign of X when S'Signed_Zeros is True.


In this case, "going and finding" is just "pointing and clicking".
I'm not saying, "hey RTFM", I'm just trying to show that getting a
copy of the ARM for this sort of thing is much more time saving and
easy than posting for such answers...

BTW, I think you're going to like Ada95.

/Jon

-- 
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178

617.484.3383
jsa@organon.com





  reply	other threads:[~1996-05-23  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-05-22  0:00 Integer truncation and other recipes Paul Shedlarski
1996-05-23  0:00 ` Jon S Anthony [this message]
1996-06-04  0:00   ` Jon S Anthony
1996-06-05  0:00     ` Norman H. Cohen
1996-06-04  0:00   ` John English
1996-06-05  0:00   ` Robert I. Eachus
1996-06-08  0:00   ` Jon S Anthony
replies disabled

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