[Lazarus] Converting pence into pounds and then to string

Howard Page-Clark hdpc at talktalk.net
Wed Dec 12 16:21:47 CET 2012


>  > > How's the best way of converting an integer number "208" (that is
>  > > pence) into a string value that is in pounds (2.08)

Here's another variant that provides an optional $, £ or €

uses math;
function PenceToString(pennies: integer; precision: integer=2;
                        currency: string=''): string;
begin
  Result:= Format(Format(currency+'%%.%df',[precision]),
                  [pennies/(10**precision)]);
end;






More information about the Lazarus mailing list