weird asfloat and value issue
Posted: Thu 27 Dec 2007 19:44
Hello,
I have a table with a value that I can see on the grid its 1.7
I assign the value to a variable
var
TotalValue: Real;
begin
TotalValue := DM.MemberSearch.FieldByName('debt').AsFloat;
ShowMessage(FloatToStr(TotalValue));
and it says 1.70
then I execute the code:
ShowMessage(FloatToStr(TotalValue - 1.70));
and instead of 0 I receive
-4,44522890719057E-17
Very weird because If I change the first line with
TotalValue := StrToFloatDef(DM.MemberSearch.FieldByName('debt').AsString, 0);
The result is 0. Which means that something is wrong with "AsFloat" assignment.
[EDIT] debt field in mysql is Decimal 6,2
Any idea?
I have a table with a value that I can see on the grid its 1.7
I assign the value to a variable
var
TotalValue: Real;
begin
TotalValue := DM.MemberSearch.FieldByName('debt').AsFloat;
ShowMessage(FloatToStr(TotalValue));
and it says 1.70
then I execute the code:
ShowMessage(FloatToStr(TotalValue - 1.70));
and instead of 0 I receive
-4,44522890719057E-17
Very weird because If I change the first line with
TotalValue := StrToFloatDef(DM.MemberSearch.FieldByName('debt').AsString, 0);
The result is 0. Which means that something is wrong with "AsFloat" assignment.
[EDIT] debt field in mysql is Decimal 6,2
Any idea?