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?
Is there an Industry standard one?
Further to this, is anyone away of legally what the obligations would
be when the outcome is 3.566666667? does the customer get 56 or 57p?
Do I need to track the remaining .003333 and use it in other
operations?
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?
Surely it can lead to bugs and changing a data type later in
development can allow bitwise and maths operations to become un-
trustable? In my own applications I have been typdef'ing structures
merely to remove the requirement to write "struct" everywhere and I
see how shortening the name of unsigned long to ulng would be useful
but I don't see it's benefit in some cases. So why do people use it?
I'm sorry if these questions seem stupid or simple but I'm new to C
and I can't find that many resources for C.
Phillip Taylor
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?
Is there an Industry standard one?
Further to this, is anyone away of legally what the obligations would
be when the outcome is 3.566666667? does the customer get 56 or 57p?
Do I need to track the remaining .003333 and use it in other
operations?
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?
Surely it can lead to bugs and changing a data type later in
development can allow bitwise and maths operations to become un-
trustable? In my own applications I have been typdef'ing structures
merely to remove the requirement to write "struct" everywhere and I
see how shortening the name of unsigned long to ulng would be useful
but I don't see it's benefit in some cases. So why do people use it?
I'm sorry if these questions seem stupid or simple but I'm new to C
and I can't find that many resources for C.
Phillip Taylor
Comment