hpeter
asked on
String->Single value (StrToFloat doesn't work in D3)
How can I convert string to single value? StrToFloat get an extended value.
Example:
var e:single;
...
e:=StrToFloat('0,0475');
and e=0,0474999... And this is my problem.
An idea?
Thank's
Example:
var e:single;
...
e:=StrToFloat('0,0475');
and e=0,0474999... And this is my problem.
An idea?
Thank's
Use Double instead of Single
ASKER
Double is an 8-byte number. But I need an 4-byte number from the string.
Don't really understand. Do you want the result in your example to be a real with just 4 decimal places - 4.0475 ?
Use the val function: e.g.
var r : real;
code : integer;
begin;
val('12.345', r, code);
if Code <> 0 then error;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hpeter:
Single is just not precise enough. Why does it have to be Single?
Single is just not precise enough. Why does it have to be Single?