comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey Creem" <jeff@thecreems.com>
Subject: Re: how to round integers
Date: Mon, 16 Jun 2003 21:59:56 GMT
Date: 2003-06-16T21:59:56+00:00	[thread overview]
Message-ID: <o5rHa.2405$Fa6.1859@sccrnsc02> (raw)
In-Reply-To: VkbHa.72213$%42.66485@fed1read06


"Charles LaCour" <clacour1@cox.net> wrote in message
news:VkbHa.72213$%42.66485@fed1read06...
> You would get 8 2/3 which becomes 8.66666....  This rounds up to nine
> because .6 >= .5
>
> I'm not an Ada programmer, but this question is not about Ada so I thought
> it would be ok.
>

Oh well..Thanks for trying.  You are correct that this is not about Ada but
you are incorrect
about the answer. Integer math (C, Ada, C++, etc) truncates. It does not
round. It would not matter
if the fraction were 0.99999999   it would still truncate.

If you did the work in float and converted to an integer, it would of course
round but I don't think that is what the original poster was asking.






  parent reply	other threads:[~2003-06-16 21:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-16  2:55 how to round integers Cephus�
2003-06-16  4:03 ` Charles LaCour
2003-06-16 12:12   ` Cephus�
2003-06-16 21:59   ` Jeffrey Creem [this message]
2003-06-16 10:09 ` Martin Dowie
2003-06-16 10:49 ` David C. Hoos
2003-06-16 12:18 ` how to round integers (Figured it out!) Cephus�
2003-06-16 12:34   ` David C. Hoos
2003-06-16 12:36     ` Cephus�
2003-06-16 13:12       ` David C. Hoos
2003-06-17  4:44         ` Robert I. Eachus
2003-06-17 19:20           ` Jeffrey Carter
2003-06-18  9:32             ` Robert I. Eachus
2003-06-18 18:07               ` Jeffrey Carter
2003-06-19  0:34                 ` Robert I. Eachus
2003-06-19 23:40                   ` Jeffrey Carter
replies disabled

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