@@ -193,6 +193,7 @@ bool string_isNotStringNumericZeroValue_and_totalCharIsEqualOrUnder(const QStrin
193193 bool &bTotalCharIsEqualOrUnder) {
194194
195195 qDebug () << __FUNCTION__<< " return: str =" << str;
196+ qDebug () << __FUNCTION__<< " totalCharIsEqualOrUnder to check:" << totalCharIsEqualOrUnder;
196197
197198 bIsNotStringNumericZeroValue = false ;
198199 bTotalCharIsEqualOrUnder = false ;
@@ -221,6 +222,10 @@ bool string_isNotStringNumericZeroValue_and_totalCharIsEqualOrUnder(const QStrin
221222
222223bool stringNumericValue_isComplianWithMaxBeforeDottMaxAfterDot (const QString& str, int maxBeforeDot, int maxAfterDot) {
223224
225+ qDebug () << __FUNCTION__ << " str = " << str;
226+ qDebug () << __FUNCTION__ << " maxBeforeDot = " << maxBeforeDot;
227+ qDebug () << __FUNCTION__ << " maxAfterDot = " << maxAfterDot;
228+
224229 int textSize = str.size ();
225230 if (!textSize) {
226231 return (false );
@@ -241,13 +246,59 @@ bool stringNumericValue_isComplianWithMaxBeforeDottMaxAfterDot(const QString& st
241246}
242247
243248bool isConformToFormatPrecision (double dValue, int maximumDecimalForStringConversion, int maxCharCountInString) {
244- // convert using maximum decimal as maximumDecimalForStringConversion
245- QString strOf_dValue = doubleToQStringPrecision_f_amountOfDecimal (dValue, maximumDecimalForStringConversion);
249+ // convert using maximum decimal with more than maximumDecimalForStringConversion
250+ QString strOf_dValue = doubleToQStringPrecision_f_amountOfDecimal (dValue, maximumDecimalForStringConversion+4 );
251+ qDebug () << __FUNCTION__ << " #1 strOf_dValue = " << strOf_dValue;
252+
246253 // remove useless zero
247254 strOf_dValue = removeUselessZerosInNumericValueString_withoutSign_and_oneDecimalDotMaximum (strOf_dValue);
255+ qDebug () << __FUNCTION__ << " #2 strOf_dValue = " << strOf_dValue;
256+
257+ bool bCompliant = stringNumericValue_isComplianWithMaxBeforeDottMaxAfterDot (strOf_dValue,
258+ maxCharCountInString,
259+ maximumDecimalForStringConversion);
260+ qDebug () << __FUNCTION__ << " bCompliant: " << bCompliant;
261+ if (!bCompliant) {
262+ return (false );
263+ }
264+
248265 return (string_isNotStringNumericZeroValue_and_totalCharIsEqualOrUnder (strOf_dValue, maxCharCountInString));
249266}
250267
268+ bool isConformToFormatPrecision_zeroValueIsAccepted (double dValue, int maximumDecimalForStringConversion, int maxCharCountInString,
269+ bool & bIsNotStringNumericZeroValue) {
270+ // convert using maximum decimal with more than maximumDecimalForStringConversion
271+ QString strOf_dValue = doubleToQStringPrecision_f_amountOfDecimal (dValue, maximumDecimalForStringConversion+4 );
272+ qDebug () << __FUNCTION__ << " #1 strOf_dValue = " << strOf_dValue;
273+
274+ // remove useless zero
275+ strOf_dValue = removeUselessZerosInNumericValueString_withoutSign_and_oneDecimalDotMaximum (strOf_dValue);
276+ qDebug () << __FUNCTION__ << " #2 strOf_dValue = " << strOf_dValue;
277+
278+ bool bCompliant = stringNumericValue_isComplianWithMaxBeforeDottMaxAfterDot (strOf_dValue,
279+ maxCharCountInString,
280+ maximumDecimalForStringConversion);
281+ qDebug () << __FUNCTION__ << " bCompliant: " << bCompliant;
282+ if (!bCompliant) {
283+ return (false );
284+ }
285+
286+ /* bool*/ bIsNotStringNumericZeroValue = false ;
287+ bool bTotalCharIsEqualOrUnder = false ;
288+ /* bool bReport = */ string_isNotStringNumericZeroValue_and_totalCharIsEqualOrUnder (strOf_dValue, maxCharCountInString,
289+ bIsNotStringNumericZeroValue,
290+ bTotalCharIsEqualOrUnder);
291+ if (!bTotalCharIsEqualOrUnder) {
292+ return (false );
293+ }
294+ // here if bTotalCharIsEqualOrUnder is true
295+
296+ // bIsNotStringNumericZeroValue true of false, it's ok
297+ return (true );
298+ }
299+
300+
301+
251302bool floatToDoubleWithReducedPrecision (double dValue, int precision, double & dValueOut) {
252303
253304 qDebug () << __FUNCTION__ << " #0 strOf_dValue = " << dValue;
0 commit comments