[Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Richard Mace
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 --

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Kostas Michalopoulos
Perhaps not the most efficient solution but that would do: // p is the integer, f.e. 208 IntToStr(p div 100) + '.' + IntToStr((p mod 100) div 10) + IntToStr(p mod 10) On Wed, Dec 12, 2012 at 12:23 PM, Richard Mace richard.m...@gmail.comwrote: Hi All, Got a simple question that has stumped

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Graeme Geldenhuys
On 2012-12-12 11:23, Richard Mace wrote: How's the best way of converting an integer number 208 (that is pence) into a string value that is in pounds (2.08) Divide by 100. Then use FormatFloat() to output as string. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Henry Vermaak
On Wed, Dec 12, 2012 at 11:23:46AM +, 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

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Lukasz Sokol
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

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Richard Mace
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...@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

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Sven Barth
Am 12.12.2012 13:17 schrieb Lukasz Sokol el.es...@gmail.com: 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

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Howard Page-Clark
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:

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Lukasz Sokol
On 12/12/2012 15:21, Howard Page-Clark wrote: 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:

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Lukasz Sokol
On 12/12/2012 15:42, Lukasz Sokol wrote: On 12/12/2012 15:21, Howard Page-Clark wrote: 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

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Lukasz Sokol
On 12/12/2012 15:45, Lukasz Sokol wrote: Format('%s%%.%df',[currency, precision]),[pennies/(10**precision)]); Fat fingers L( Format(Format('%s%%.%df',[currency, precision]),[pennies/(10**precision)]); of course! No ? :) Lukasz --

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Mark Morgan Lloyd
Howard Page-Clark wrote: 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;

Re: [Lazarus] Converting pence into pounds and then to string

2012-12-12 Thread Marco van de Voort
On Wed, Dec 12, 2012 at 11:23:46AM +, Richard Mace wrote: 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)