Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- DECIMALS = 4; // "accuracy"
- FLOAT = 1.23456;
- function FracAcc(x: Extended; a: Integer): Extended;
- var
- d: Extended;
- z: Boolean;
- begin
- Result := Int(x);
- if (a > 0) then
- begin
- d := DecRet(x);
- z := (d < 0.1);
- if z then
- d := (d + 0.1);
- Result := (Result + StrToFloatDef(('.' + Copy(FloatToStr(d), 3, a)), 0));
- if z then
- Result := (Result - 0.1);
- end else
- Result := 0;
- end;
- begin
- WriteLn(FloatToStr(FracAcc(FLOAT, DECIMALS)));
- end.
Advertisement
Add Comment
Please, Sign In to add comment