ADOQuery和ADOTable有个属性EnableBCD,把它设为true还是false?两者有何区别?

Spring414 2003-08-13 12:38:13
谢谢。
...全文
378 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhpsam109 2003-08-13
  • 打赏
  • 举报
回复
学习!
csdnxw 2003-08-13
  • 打赏
  • 举报
回复
如果EnableBCD设为true ,则adDecimal and adNumeric 字段从数据库读出来后放在TBCDField类中,这种类表示数值比较精确,而如果EnableBCD为false则所有的adDecimal\adNumeric\adFloat型的数据都以float型读出来,这样会对数据的精确度有一定的影响。
因为就像英文例子所述:
使用BCD型: 3 * (2/3) = 2
使用Float型:3 * (2/3) = 2.00000000001
Spring414 2003-08-13
  • 打赏
  • 举报
回复
如果英文看得明明白白了,也就不会来问了。唉。
Spring414 2003-08-13
  • 打赏
  • 举报
回复
不是太明白。
lvjack 2003-08-13
  • 打赏
  • 举报
回复
BCB的帮助不是说了么?
Specifies whether to treat numeric fields as floating-point or BCD.

__property bool EnableBCD = {read=FEnableBCD, write=FEnableBCD, default=1};

Description

Use the EnableBCD property to specify how fields are mapped to field classes. If EnableBCD is true, (the default value) adDecimal and adNumeric fields are mapped to the TBCDField class when field objects are created. If EnableBCD is false, the fields are mapped to the TFloatField class.

EnableBCD determines whether numeric and decimal fields are translated as floating-point values or binary coded decimal (BCD) values. BCD values eliminate the rounding errors associated with floating point math (such as a 3 * (2/3) resulting in 2.00000000001).

If persistent field objects are used (such as those created using the Fields Editor), the field class associated with a given field can contradict the setting of EnableBCD. Three numeric fields in the same table could, for instance, each be represented by a TFloatField, a TBCDField, and a TVariantField ?regardless of the value in EnableBCD. Select field classes on a field-by-field basis for greater flexibility.

Note: For numeric values with more than 4 digits to the right of the decimal place, use of TFloatField is generally better. This is because TBCDField uses the currency data type that has a fixed scale of 4 decimal places.
Note: For fields with very large numbers of more than 19 significant digits, you can use TVariantField type persistent field objects. The TFloatField and TBCDField classes lack sufficient capacity for fields of this size. TVariantField allows the getting and setting of the field data as strings, preventing without loss of data due to insufficient capacity. However, arithmetic operations cannot be performed on numbers accessed through a TVariantField object.

13,865

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧