When should I choose decimal over float and vice versa?
Mike BYou should always use a decimal if your data is definable. If it's not and you requiret the ability to perform float operations, you should use float. This should be rare or never. It's better to define the scope of the data in the planning stage.|||I use DECIMAL for things that are really counts of something, like money. I use FLOAT for things that are measures, like distance or most kinds of weight. The two usages are fundamentally different, and the implementations (both from a storage and a manipulation perspective) are different too. It rarely works well if you use the wrong one!
-PatP|||Yeah, you don't really want your accounting application to use FLOAT. (grin)|||Yeah, you don't really want your accounting application to use FLOAT. (grin)Now that isn't entirely true!
If you work for the kind of business that thinks about money in terms of "3 inches of $50 bills", then I'd have no problem with using a FLOAT. This would also make it lots easier to handle the conversion between money and grams of product too!
I don't know of anybody that does accounting that way, but if they did then I'd be fine with the idea of using reals in that particular accounting system! ;) The rest of us will have to make do with using more conventional things like MONEY or DECIMAL columns.
-PatP
没有评论:
发表评论