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,9316ecaabdc23114 X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Rounded off Date: 1999/06/09 Message-ID: #1/1 X-Deja-AN: 487752034 Content-Transfer-Encoding: 7bit References: <7jmq0c$uq$1@nnrp1.deja.com> X-Priority: 3 Content-Type: text/plain; charset="iso-8859-1" X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-MSMail-Priority: Normal MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-06-09T00:00:00+00:00 List-Id: wrote in message news:7jmq0c$uq$1@nnrp1.deja.com... > In article , > dginc@tds.net wrote: > > i am wondering how to have my output come out rounded insted of with > > decimals?? the output is 19.8 figured from calculation, i want it to > output > > that rounded off (20). the calculation is from float a decimal and > input is a > > whole number. any suggestions > > > > > How about: > Integer(X + 0.5) > The above suggestion will give wrong results for negative numbers. Real values are already rounded on conversion to Integer (RM 4.6 (33), viz.: If the target type is an integer type and the operand type is real, the result is rounded to the nearest integer (away from zero if exactly halfway between two integers). So simply Integer (X) will give correct results for all values of X within the range of type Integer. For rounding to, say, the nearest 0.01, one should use an instantiation of the appropriate generic package from Ada.Text_IO, and use an Aft value of 2 when calling the Put procedure. Rounding is done by the Put procedure.