[fpc-pascal] Currency symbol wrong location

Marco van de Voort marcov at stack.nl
Sat Jun 9 17:43:59 CEST 2012


In our previous episode, Leonardo M. Ram? said:
> Hi, I want to format a float number to currency. To do this, I use the Format function using the %m format, as this:

> Format('%m', [123.25]);

>I'm using Ubuntu 12.04 and my regional settings at configured to display "$ 1234.25", but I'm getting "123.25$", why is the money symbol at the right side, instead of using the regional setting?.

This is as per doc?

http://www.freepascal.org/docs-html/rtl/sysutils/format.html

FloatToStrF(Argument,ffGeneral,Precision,3)

M    Currency format. the next argument in the var{Args} array must be a
floating point value. The argument is converted to a decimal string using
currency notation. This means that fixed-point notation is used, but that
the currency symbol is appended. If precision is specified, then then it
overrides the CurrencyDecimals global variable used in the FloatToStrF

    In short, the M specifier formats it's argument as follows:

    FloatToStrF(Argument,ffCurrency,9999,Precision)

Note the /append/  :-)






More information about the fpc-pascal mailing list