Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #16084
| From | "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Another little puzzle |
| Date | 2022-12-14 16:43 +0100 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <tncquh$vj3$1@gioia.aioe.org> (permalink) |
| References | (3 earlier) <tncjem$19kh$1@gioia.aioe.org> <tnclg3$2of9o$2@dont-email.me> <tncob5$1oat$1@gioia.aioe.org> <tncpgk$2of9h$7@dont-email.me> <tncqs4$uoe$1@gioia.aioe.org> |
On 2022-12-14 16:41, Dmitry A. Kazakov wrote:
> On 2022-12-14 16:18, Richard Heathfield wrote:
>
>>> BTW, averaging floats is a nasty problem too. A naive implementation
>>> quickly loses precision.
>>
>> We're dealing with 'o'clock' and "HH:MM", and nowadays we have 64-bit
>> integer types and there are even 128-bit integers mooching around
>> looking for a reason to exist. You'd have to average a hell of a lot
>> of times even to /need/ floats, let alone lose significant precision.
>
> I never suggested float for averaging time stamps, I pointed out that
> averaging is not a simple problem. E.g. try this one:
>
> function Average (X : Float; N : Positive) return Float is
> Sum : Float := 0.0;
> begin
> for Index in 1..N loop
> Sum := Sum + X;
> end loop;
> return Sum / Float (N);
> end Average;
>
> The function does naive averaging. For simplicity it just sums up the
> same number X N times and divides by N.
>
> Average (1.0, 17_000_000) = 0.986895
> Average (1.0, 100_000_000) = 0.167772
> Average (1.0, 200_000_000) = 0.838861
0.0838861
The error is obviously systematic.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-14 14:06 +0100
Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-14 13:10 +0000
Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-14 14:35 +0100
Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-14 14:10 +0000
Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-14 15:58 +0100
Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-14 15:18 +0000
Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-14 16:41 +0100
Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-14 16:43 +0100
Re: Another little puzzle Y A <angel00000100000@mail.ee> - 2023-01-09 16:33 -0800
Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-14 16:13 +0000
Re: Another little puzzle V <angleeeeeeee@mail.ee> - 2023-05-10 11:16 -0700
Re: Another little puzzle Ǝ <angel0000000001000000000000@mail.ee> - 2022-12-30 05:59 -0800
csiph-web