From: "Cephus�" <beau@hiwaay.net>
Subject: Re: how to round integers
Date: Mon, 16 Jun 2003 07:12:08 -0500
Date: 2003-06-16T07:12:08-05:00 [thread overview]
Message-ID: <verd0l9ekm6515@corp.supernews.com> (raw)
In-Reply-To: VkbHa.72213$%42.66485@fed1read06
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 968 bytes --]
Charles LaCour wrote:
> 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.
>
> "Cephus�" <beau@hiwaay.net> wrote in message
> news:veqcdrsf7o7q57@corp.supernews.com...
>> I am trying to remember the "golden rule" for integer division
>> rounding.
>>
>> I am trying to average something (both integers) and I can't
>> remember how to round without using floating point.
>>
>> Like say I am trying to divide 26/3 --- I would get 8 remainder 2
>>
>> but that should round up to 9. How can I do this? I know it has
>> something to do with the dividend....but I can't for the life of me
>> remember. thanks!
>>
>> Beau
no you can't do this because if you don't specifically type cast an integer
into a float, you have no decimals. So if you say 26/3, you just get 8 in
your variable...in other words it truncates the integer...
next prev parent reply other threads:[~2003-06-16 12:12 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� [this message]
2003-06-16 21:59 ` Jeffrey Creem
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