From 15b5b3b3f01e400e46fe67babe593ede373dac4b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 19 Oct 2015 14:52:19 +0200 Subject: Add flags to omit/reject padding in scientific notation exponents The EcmaScript format for printing doubles in exponent form differs from Qt's format only in this aspect. EcmaScript explicitly prohibits leading zeroes in exponents. It is thus worthwhile to add those flags in order to be able to generate and parse doubles in compliance with EcmaScript. [ChangeLog][QtCore][QLocale] Additional flags in QLocale::NumberOption allow generating and parsing doubles in EcmaScript compliant format. Change-Id: Ia7b82c2e67bb8b80bd890014ff5cd4563faf2a03 Reviewed-by: Lars Knoll --- src/corelib/tools/qlocale_tools.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/corelib/tools/qlocale_tools.cpp') diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp index 890f63af0a..cdc654904e 100644 --- a/src/corelib/tools/qlocale_tools.cpp +++ b/src/corelib/tools/qlocale_tools.cpp @@ -495,7 +495,8 @@ QString &exponentForm(QChar zero, QChar decimal, QChar exponential, QChar group, QChar plus, QChar minus, QString &digits, int decpt, int precision, PrecisionMode pm, - bool always_show_decpt) + bool always_show_decpt, + bool leading_zero_in_exponent) { int exp = decpt - 1; @@ -515,7 +516,7 @@ QString &exponentForm(QChar zero, QChar decimal, QChar exponential, digits.append(exponential); digits.append(QLocaleData::longLongToString(zero, group, plus, minus, - exp, 2, 10, -1, QLocaleData::AlwaysShowSign)); + exp, leading_zero_in_exponent ? 2 : 1, 10, -1, QLocaleData::AlwaysShowSign)); return digits; } -- cgit v1.2.3