Re: 5-byte numbers
- From: spamgate@xxxxxxxxxxx (ML)
- Date: Fri, 26 Jun 2009 21:25:25 +0200
And if this is not an option use double.
Thanks. I novicely overlooked that as a candidate, preferably without
having to install another compiler for "long long" (albeit I've access,
to all newer OS/2 ones, but not everywhere).
no rounding errors as long as your numbers are integral and fit into
the mantissa.
I don't know for 100% sure what the mantissa is. The numbers indeed are
unsigned integers (cumulative volume of traded shares). YMMV, but I'll
be fine with a readable 12 digits for the sum(200). I've read a manual,
and saw it can hold 15 digits (with a sizeof() 8 bytes).
But there's a problem. Perhaps as silly as overlooking a "double". I've
finished a Rexx'ish solution faster than I've found out how to output
a double with a result other than "0", as in (very briefly):
double d;
d=65536*65536*16;
printf("d=%lu\n",d/128);
Please note that, AFAIK, using ".2" decimals with the printf()-family
also introduces an additional rounding problem. Survivable, but it's
something to keep in mind then.
I could post the nearly finished Rexx'ish solution, including expected
rounding, but IMO that math is too simple to have any generic use: add
numbers one-by-one, and divide the result by 40 (to obtain a ratio of
5:200 as %.2f, in the end).
volume[i]=random(65536*1024);
Since your result is an approximate number anyway
In a way, yes. But the result is verifyable, as if my random()-function
also sends the result to a leading financial newspaper. It illustrates
that the outcome (=sum(200)) may exceed an ULONG, but not always. Last
week the smallest gap in the Top-10 was 0.03 (rounded), and it's hardly
more than a short-list. And some error in a result may be the biggest
surpise ever to be seen, if noticed at all.
Nevertheless I'll also give your other calculated solution a try. It's
both easy and interesting to compare its results with the current Rexx-
based results (C preprocessing, Rexx finishing). And I may even get a
double working, assuming 15 digits are readable with an "E" in there.
---
.
- Follow-Ups:
- Re: 5-byte numbers
- From: Marcel Müller
- Re: 5-byte numbers
- From: Dave Saville
- Re: 5-byte numbers
- References:
- 5-byte numbers
- From: ML
- Re: 5-byte numbers
- From: Marcel Müller
- 5-byte numbers
- Prev by Date: Re: 5-byte numbers
- Next by Date: Re: 5-byte numbers
- Previous by thread: Re: 5-byte numbers
- Next by thread: Re: 5-byte numbers
- Index(es):
Relevant Pages
|
Loading