RAD Studio VCL Reference
TADODataSet.EnableBCD Property

Specifies whether to treat numeric fields as floating-point or BCD.

property EnableBCD: Boolean;
__property Boolean EnableBCD;

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.


Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!