From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ac48cedaf5c5cba3 X-Google-Attributes: gid103376,public From: jsa@organon.com (Jon S Anthony) Subject: Re: Integer truncation and other recipes Date: 1996/05/23 Message-ID: #1/1 X-Deja-AN: 156239467 sender: news@organon.com (news) references: <4nv3tmINNql5@oasys.dt.navy.mil> organization: Organon Motives, Inc. newsgroups: comp.lang.ada Date: 1996-05-23T00:00:00+00:00 List-Id: 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