Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- FLOAT = 17.84848484;
- function DecAcc(x: Extended; accuracy: Integer): Extended;
- var
- t: Extended;
- s: string;
- l: Integer;
- begin
- if (accuracy > 0) then
- begin
- // FAILSAFES:
- s := FloatToStr(DecRet(x));
- if (s <> '0') then
- begin
- l := (Length(s) - 2);
- if (accuracy > l) then
- accuracy := l;
- end else
- accuracy := 0;
- // ----------
- t := Pow(10, accuracy);
- Result := (Floor(x * t) / t);
- end else
- Result := Int(x);
- end;
- var
- i: Integer;
- begin
- ClearDebug;
- for i := -1 to 9 do
- WriteLn(FloatToStr(DecAcc(FLOAT, i)) + ' [FLOAT at Accuracy: ' + IntToStr(i) + ']');
- end.
Advertisement
Add Comment
Please, Sign In to add comment