[Lazarus] Converting pence into pounds and then to string

Richard Mace richard.mace at gmail.com
Wed Dec 12 13:32:12 CET 2012


Guy's,
Thanks for the quick info. It's brilliant to get so many good answers do
quickly.

Richard


On 12 December 2012 12:17, Lukasz Sokol <el.es.cr at gmail.com> wrote:

> On 12/12/2012 11:23, Richard Mace wrote:
> > Hi All, Got a simple question that has stumped me, which tends to
> > happen if I don't do development for a couple of months.
> >
> > How's the best way of converting an integer number "208" (that is
> > pence) into a string value that is in pounds (2.08)
> >
> > Thanks as always in advance.
> >
> > Richard
> >
> >
> -ENOTENOUGHINFO (do you assume 2 decimal places always?)
>
> but simplest variable precision would probably be
>
> function PenceToString(ANumber: integer; APrecision : integer = 2):string
> begin
>   Result := Format('%.'+IntToStr(APrecision)'f',[ANumber div
> (10**APrecision)]);
> end;
>
> :] (assuming the ** operator actually works)
>
> L.
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20121212/85098cc7/attachment-0003.html>


More information about the Lazarus mailing list