Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.programming    |    Programming issues that transcend langua    |    57,431 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 56,770 of 57,431    |
|    Dmitry A. Kazakov to Dmitry A. Kazakov    |
|    Re: Another little puzzle    |
|    14 Dec 22 16:43:14    |
      From: mailbox@dmitry-kazakov.de              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              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca