comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: how to round integers (Figured it out!)
Date: Thu, 19 Jun 2003 23:40:27 GMT
Date: 2003-06-19T23:40:27+00:00	[thread overview]
Message-ID: <3EF249D6.5050904@spam.com> (raw)
In-Reply-To: 3EF10509.7040103@attbi.com

Thanks for the timings. I suspected that converting to floating-point 
would be faster.

Robert I. Eachus wrote:
> 
>   generic
>     type Int is range <>;
>   function Rounding2(Dividend, Divisor: Int) return Int;
> 
>   function Rounding2(Dividend, Divisor: Int) return Int is
>   begin
>     return Int(Long_Float(Dividend)/Long_Float(Divisor));
>   end Rounding2;

Except that Long_Float is (technically) not portable; implementations 
are not required to define Long_Float. So I guess the fully portable way 
to implement this would be

with System;
function Rounding2 (Dividend, Divisor: Int) return Int is
    type Big is digits System.Max_Digits;
begin -- Rounding2
    return Int (Big (Dividend) / Big (Divisor) );
end Rounding2;

-- 
Jeff Carter
"You cheesy lot of second-hand electric donkey-bottom biters."
Monty Python & the Holy Grail




      reply	other threads:[~2003-06-19 23:40 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
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 [this message]
replies disabled

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