QuickTopic (SM) free message boards QuickTopic (SM) free message boards
Skip to Messages
  Sign In to access your topic list  |New Topic |My Topics|Profile
Upgrade to Pro   Customize, show pictures, add an intro, and more:   QuickTopic Pro...and check out QuickThreadSM
Topic: Storing fixed point numbers in MySQL
Views: 3368, Unique: 1688 
Subscribers: 1
What's
this?
Printer-Friendly Page
Subscribe to get & post, or stop messages by email Subscribe
All messages    << 11-16  10-10 of 16  1-9 >>
About these ads
Who | When
Messagessort recent-top   
Post a new message
 
AHandsPerson was signed in when posted  10
01-04-2005 06:16 AM ET (US)
Edited by author 01-04-2005 07:16 AM
You realize the problem is an imcompatibility between binary and decimal right?
One tenth (1/1010) works out to:
0.0001100110011001100...
(try it long hand on a whiteboard)

It's perfectly precise for eigths for example, but not for tenths (or hundreths). IEEE floating point is great for engineering, but...ah...suboptimal for accounting. Just as decimal is lousy for sevenths, binary is lousy for decimal. If only the Mohenjo Daro had ignored their thumbs we could've all been raised on octal, bitwise shifts and rotates would be easy to grasp...

I don't think thats why Wall Street prices stocks in eigths, but I think its why they'll run into more trouble than they expect if they ever try to switch to decimals. The problem is far from limited to MySQL.

Doing your storage and math in pennies and only converting to dollars when you want to print/display is the best way to go. It's fast and precise.
RSS link What's this?
All messages    << 11-16  10-10 of 16  1-9 >>
QuickTopicSM message boards
Over 200,000 topics served
Learn more Frequently asked questions  Acknowledgements
What they're saying about QuickTopic
 Questions, comments, or suggestions? Contact Us
Read our use policy before beginning. We value your privacy; please read our privacy statement.
Copyright ©1999-2008 Internicity Inc. All rights reserved.