Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > Working with Ca...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 1081 of 1099
Post > Topic >>

Working with Cash and uses of Typedef

by Philluminati <Phillip.Ross.Taylor@[EMAIL PROTECTED] > Apr 16, 2008 at 04:57 PM

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 =A310.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
-- 
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.




 6 Posts in Topic:
Working with Cash and uses of Typedef
Philluminati <Phillip.  2008-04-16 16:57:04 
Re: Working with Cash and uses of Typedef
Carl Barron <cbarron41  2008-04-18 16:11:08 
Re: Working with Cash and uses of Typedef
Keith Thompson <kst-u@  2008-04-21 13:18:44 
Re: Working with Cash and uses of Typedef
=?ISO-8859-1?Q?Hans-Bernh  2008-04-18 16:11:16 
Re: Working with Cash and uses of Typedef
Thomas Richter <thor@[  2008-04-18 16:11:18 
Re: Working with Cash and uses of Typedef
Brian Inglis <Brian.In  2008-04-18 16:12:04 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 2:26:29 CDT 2008.