Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-09

FormatFloat('#,##.00', -1) -> .-1,00

7 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

John Landmesser

the function FormatFloat delivers a bad formatted negative value with(!) the dot from ThousandSeparator.

In sysint.inc i found:

{ Character that is put every 3 numbers in a currency } ThousandSeparator : Char absolute
DefaultFormatSettings.ThousandSeparator *deprecated*;

Does "*deprecated" *mean that this is no error and will not be fixed?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150907/9fd5e306/attachment.html>

Reply by email

Michael Van Canneyt
to John Landmesser
John Landmesser wrote 10 lines
the function FormatFloat delivers a bad formatted negative value with(!) the dot from ThousandSeparator. In sysint.inc i found: { Character that is put every 3 numbers in a currency } ThousandSeparator : Char absolute DefaultFormatSettings.ThousandSeparator *deprecated*; Does "*deprecated" *mean that this is no error and will not be fixed?

No. It means that you must use DefaultFormatSettings.ThousandSeparator instead of ThousandSeparator

Michael.

Reply by email

John Landmesser
to John Landmesser: the function FormatFloat delivers a bad formatted negative value with(!) the dot from…

forgot to mention:

Lazarus 1.5 r49771 FPC 2.6.4 x86_64-linux-gtk 2

John Landmesser wrote 18 lines
the function FormatFloat delivers a bad formatted negative value with(!) the dot from ThousandSeparator. In sysint.inc i found: { Character that is put every 3 numbers in a currency } ThousandSeparator : Char absolute DefaultFormatSettings.ThousandSeparator *deprecated*; Does "*deprecated" *mean that this is no error and will not be fixed? -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150907/f26ae76d/attachment.html>

Reply by email

Werner Pamler
to John Landmesser: the function FormatFloat delivers a bad formatted negative value with(!) the dot from…
Show quoted text 8 lines
the function FormatFloat delivers a bad formatted negative value with(!) the dot from ThousandSeparator. In sysint.inc i found: { Character that is put every 3 numbers in a currency } ThousandSeparator : Char absolute DefaultFormatSettings.ThousandSeparator *deprecated*;

The format '#,##0.00' means: Format the number with two decimal places, even if it is an integer. Replace the dot by
DefaultFormatSettings.DecimalSeparator. If the number is greater than 1000 (or less than -1000) add a thousand separator, replace the comma by the DefaultFormatSettings.ThousandSeparator. The '#' identifies optional digits which will be shown only when needed. The '0' identifies digits which will be shown even if the corresponding digit would be 0 (i.e. if the format string were '0,000.00' then the number 12 would be displayed as '0.012,00' if DecimalSeparator is '.' and ThousandSeparator is '.').

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150907/b62eb850/attachment.html>

Reply by email

John Landmesser
to Werner Pamler

ok , you are right, but see the problem: a negative value contains the thousandseperator where there is no value >1000

example:

thousandseperator := '|';
FormatFloat('#,##.00', -10);

result:
*|*-10,00

Werner Pamler wrote 27 lines
> the function FormatFloat delivers a bad formatted negative value > with(!) the dot from ThousandSeparator. > > In sysint.inc i found: > > { Character that is put every 3 numbers in a currency } > ThousandSeparator : Char absolute > DefaultFormatSettings.ThousandSeparator *deprecated*; The format '#,##0.00' means: Format the number with two decimal places, even if it is an integer. Replace the dot by DefaultFormatSettings.DecimalSeparator. If the number is greater than 1000 (or less than -1000) add a thousand separator, replace the comma by the DefaultFormatSettings.ThousandSeparator. The '#' identifies optional digits which will be shown only when needed. The '0' identifies digits which will be shown even if the corresponding digit would be 0 (i.e. if the format string were '0,000.00' then the number 12 would be displayed as '0.012,00' if DecimalSeparator is '.' and ThousandSeparator is '.'). -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150907/defbd8d1/attachment.html>

Reply by email

Werner Pamler
to John Landmesser
Show quoted text 6 lines
thousandseperator := '|'; FormatFloat('#,##.00', -10); result: *|*-10,00

The behavior that you observe is a bit strange, maybe it is a bug. But you can avoid it by putting three symbols between thousand and decimal separator, i.e. use '#,##0.00' or '#,###.00'.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150907/d5cc5acb/attachment-0001.html>

Reply by email

John Landmesser
to Werner Pamler

ok, no i see may mistake:

three symbols!!

'#,##0.00' or '#,###.00'

sorry!!

Werner Pamler wrote 18 lines
> thousandseperator := '|'; > > FormatFloat('#,##.00', -10); > > result: > *|*-10,00 The behavior that you observe is a bit strange, maybe it is a bug. But you can avoid it by putting three symbols between thousand and decimal separator, i.e. use '#,##0.00' or '#,###.00'. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150907/4e851a80/attachment.html>

Reply by email