From 7dfe1301c386bd7ebe65f5655b6bdba906c3e9ce Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Tue, 26 Mar 2013 18:53:37 +0000 Subject: [PATCH] * fixed type in FloatToStrFIntl introduced in r23311 (mantis #24131) git-svn-id: trunk@24013 - --- .gitattributes | 1 + rtl/objpas/sysutils/sysstr.inc | 2 +- tests/webtbs/tw24131.pp | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw24131.pp diff --git a/.gitattributes b/.gitattributes index 471d27a8c5..0469d89047 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13288,6 +13288,7 @@ tests/webtbs/tw23962.pp svneol=native#text/plain tests/webtbs/tw2397.pp svneol=native#text/plain tests/webtbs/tw24007.pp svneol=native#text/plain tests/webtbs/tw2409.pp svneol=native#text/plain +tests/webtbs/tw24131.pp svneol=native#text/plain tests/webtbs/tw2421.pp svneol=native#text/plain tests/webtbs/tw2423.pp svneol=native#text/plain tests/webtbs/tw2425.pp svneol=native#text/plain diff --git a/rtl/objpas/sysutils/sysstr.inc b/rtl/objpas/sysutils/sysstr.inc index fdec283052..3e82a29159 100644 --- a/rtl/objpas/sysutils/sysstr.inc +++ b/rtl/objpas/sysutils/sysstr.inc @@ -1205,7 +1205,7 @@ Begin fvDouble: Str(Double(Extended(Aligned(Value))):precision+7, Result); fvSingle: - Str(Single(Extended(Aligned(Value))):precision+66, Result); + Str(Single(Extended(Aligned(Value))):precision+6, Result); fvCurrency: {$ifdef FPC_HAS_STR_CURRENCY} Str(Currency(Aligned(Value)):precision+6, Result); diff --git a/tests/webtbs/tw24131.pp b/tests/webtbs/tw24131.pp new file mode 100644 index 0000000000..03539e9ed8 --- /dev/null +++ b/tests/webtbs/tw24131.pp @@ -0,0 +1,32 @@ +uses + SysUtils; +var + s: single; +begin + s := 1.00999; + FormatSettings.DecimalSeparator:='.'; + writeln(FloatToStrF(s, ffGeneral, 8, 0, FormatSettings)); + writeln(FloatToStrF(s, ffGeneral, 7, 0, FormatSettings)); + writeln(FloatToStrF(s, ffGeneral, 6, 0, FormatSettings)); + writeln(FloatToStrF(s, ffGeneral, 5, 0, FormatSettings)); + writeln(FloatToStrF(s, ffGeneral, 4, 0, FormatSettings)); + writeln(FloatToStrF(s, ffGeneral, 3, 0, FormatSettings)); + writeln(FloatToStrF(s, ffGeneral, 2, 0, FormatSettings)); + + if FloatToStrF(s, ffGeneral, 8, 0, FormatSettings)<>'1.00999' then + halt(1); + if FloatToStrF(s, ffGeneral, 7, 0, FormatSettings)<>'1.00999' then + halt(2); + if FloatToStrF(s, ffGeneral, 6, 0, FormatSettings)<>'1.00999' then + halt(3); + if FloatToStrF(s, ffGeneral, 5, 0, FormatSettings)<>'1.01' then + halt(4); + if FloatToStrF(s, ffGeneral, 4, 0, FormatSettings)<>'1.01' then + halt(5); + if FloatToStrF(s, ffGeneral, 3, 0, FormatSettings)<>'1.01' then + halt(6); + if FloatToStrF(s, ffGeneral, 2, 0, FormatSettings)<>'1' then + halt(7); + + +end.