SQLserver 中数据类型 分Exact Numeric Data Types 和Approximate Numeric Data Types
后者我为什么是非精确的。在实际使用中,建立一个Float类型数据,Input 4,然后Query出来可能就会是3.9999999  或者  4.00000001。
这又是为什么?

解决方案 »

  1.   

    在实际使用中,建立一个Float类型数据,Input   4,然后Query出来可能就会是3.9999999     或者     4.00000001。 
    这又是为什么? 
    浮点型数据本身就是这样.
    你可以改使int,numeric.
      

  2.   

    谢谢 潇洒老乌龟但我想知道是怎么样的存储方式会造成这个样的Approximate。比方我知道Int,他就是由4 bytes来存放数据的等等。那他的存放方式是什么 ?
      

  3.   

    real和float都是浮点精度型数据,属近似数据。
    numeric和decimal是精确精度型数据,属精确数据。
      

  4.   

    看一下这段:The float data types accept a parameter in the definition that determines the number
    of digits to store precisely. For example, a float(8) column precisely stores seven digits,
    and anything exceeding that is subject to rounding errors
    照我的理解, 有效位数应该是8位,含小数点前后的数字。
    是这样么?