PRECISION IN DataSet TFloat fields

Please discuss general Delphi programming topics here.

PRECISION IN DataSet TFloat fields

Postby Johan Theunissen » April 25th, 2009, 5:01 pm

How does one get the precision in a TFloat field of a DataSet set properly?

It does not seem to work when typecasting
i.e. TFloatField(XDataSet.FieldByName('CostPrice')).Precision:= 4;

All data in a data aware control such as TDBEdit will only work to a precision of 2 decimals so that any calculations based on that field will not have the neccesary accuracy, although the raw data in the underlying database will have full precision of double etc. data.

i.e. XDataSet.FieldByName('CostPrice').AsFloat:= 55.123456;
XDataSet.FieldByName('CostPrice').AsFloat * SomeNumber will not yield accurate answer to a higher precison than 2 because it seems that XDataSet.FieldByName('CostPrice').AsFloat in above calculation is used effectivly as 55.12.

Any answers please???
Johan Theunissen
Active Member
Active Member
 
Posts: 9
Joined: November 6th, 2008, 7:26 pm

Re: PRECISION IN DataSet TFloat fields

Postby Kambiz » May 10th, 2009, 1:12 pm

Delphi gets precision of float fields from definition of table. You should set the precision when you create the tables.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2421
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron