Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {==============================================================================]
- Explanation: Returns percentage of position into source.
- [==============================================================================}
- function Percent(position, source: Extended): Extended;
- begin
- if (position <> 0) then
- Result := ((Extended(position) / Extended(source)) * 100)
- else
- Result := 0.0;
- end;
- var
- x: Extended;
- begin
- ClearDebug;
- x := 100;
- WriteLn(FloatToStr(Percent(10, x)) + '%');
- x := (x + 400);
- WriteLn(FloatToStr(Percent(5, x)) + '%');
- WriteLn(FloatToStr(Percent(150, x)) + '%');
- end.
Advertisement
Add Comment
Please, Sign In to add comment