Philluminati wrote:
> I am writing a poker game which needs to work with cash. I am aware
> that there are problems with floats that make them unsuitable for
> storing money values. On top of this I may be expected to do
> operations such as £10.52 / 3. Which data type should I use instead?
Fixed-point. Simply put you keep monetary amounts in cents/pennies, not
Dollars/Pounds/Euros
> Further to this, is anyone away of legally what the obligations would
> be when the outcome is 3.566666667?
The meaning of "legal obligation" varies with the legal province (a.k.a.
"country") you're in, and sometimes even with the particular profession.
E.g. shops are generally required to round to the nearest cent,
whereas banks may be obliged to compute down to 1 percent of a penny
(with "banker's rule" rounding to make it unbiased).
> And finally, why do I see people typedef values in C and, for example,
> use size_t rather than an int? Why is the type hidden like this?
Because size_t can be equivalent to a different type, depending on the
platform and compiler settings.
--
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
-- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line. Sorry.


|