Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #16086
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Another little puzzle |
| Date | 2022-12-14 16:13 +0000 |
| Organization | Fix this later |
| Message-ID | <tncsmt$2of9o$3@dont-email.me> (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 14/12/2022 3:41 pm, 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, Yes, you did. > I pointed out > that averaging is not a simple problem. Yes, it is. > 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. You're not being naïve /enough/. The average of N instances of X is X, so just return X. Yes, if you try hard enough, you can screw anything up. So what? -- Richard Heathfield Email: rjh at cpax dot org dot uk "Usenet is a strange place" - dmr 29 July 1999 Sig line 4 vacant - apply within
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