How to manipulate and store precise numbers in sql server
How to store numbers with variable number of decimal points? there can be anywhere from 1 to 100 decimal points I guess. What's the thing with float datatype? Why do they call it approximate number? Decimal is good, but it is a fixed precisi开发者_如何学运维on datatype as far as I understand. Is there any good articles on precise numbers? My database is going to interact with .net front-end and I also need to display these precisions on the front-end.
From wiki:
The term floating point refers to the fact that the radix point (decimal point, or, more commonly in computers, binary point) can "float"; that is, it can be placed anywhere relative to the significant digits of the number. This position is indicated separately in the internal representation, and floating-point representation can thus be thought of as a computer realization of scientific notation. Over the years, several different floating-point representations have been used in computers; however, for the last ten years the most commonly encountered representation is that defined by the IEEE 754 Standard.
The advantage of floating-point representation over fixed-point (and integer) representation is that it can support a much wider range of values. For example, a fixed-point representation that has seven decimal digits with two decimal places, can represent the numbers 12345.67, 123.45, 1.23 and so on, whereas a floating-point representation (such as the IEEE 754 decimal32 format) with seven decimal digits could in addition represent 1.234567, 123456.7, 0.00001234567, 1234567000000000, and so on. The floating-point format needs slightly more storage (to encode the position of the radix point), so when stored in the same space, floating-point numbers achieve their greater range at the expense of precision.
See this http://msdn.microsoft.com/en-us/library/ms187746.aspx for fixed point data tpes.
Best you can do with a primitive data type is 38. If you really want 100 places, you could use a varchar and implement operations in your application.
精彩评论