@@ -187,12 +187,18 @@ bool test_precision_spatialResolution_or_micmac(const QVector<double>& qvectDoub
187187bool test_precision_rejectionThreshold_values ();
188188bool test_precision_rejectionThreshold (const QVector<double >& qvectDoubleToTest, bool bTestValuesAreValid);
189189
190+ void test_behavior_of_floatToDoubleWithReducedPrecision_usingInputString ();
191+
192+
193+
190194int main (int argc, char *argv[]) {
191195
192196#ifndef DEF_APP_DELIVERY_RELEASE
193197 qInstallMessageHandler (myMessageOutput); // Install the handler
194198#endif
195199
200+ test_behavior_of_floatToDoubleWithReducedPrecision_usingInputString ();
201+
196202 test_removeUselessZerosInString ();
197203
198204 check_conversionWithPrecision_testlist ();
@@ -229,6 +235,77 @@ int main(int argc, char *argv[]) {
229235
230236}
231237
238+ // floatToDoubleWithReducedPrecision handles correctly string numeric content to numeric value when < 1000
239+ // numeric values > 999.999 with decimal tends to add extra 0.0001 which fails the remove useless zero in decimals operation
240+ // example with string "1234.56" => 1234.56 => "1234.5601"
241+ void test_behavior_of_floatToDoubleWithReducedPrecision_usingInputString () {
242+
243+ bool bOk = false ;
244+ QStringList qStrListV= { " 1.2345" ,
245+ " 1.23450" ,
246+ " 12.345" ,
247+ " 12.3450" ,
248+ " 123.45" ,
249+ " 123.450" ,
250+ " 123.456" ,
251+ " 123.4560" ,
252+ " 1234.56" ,
253+ " 1234.560" ,
254+ " 12345.6" ,
255+ " 12345.60" ,
256+ " 12345.600" ,
257+
258+ " 1000" ,
259+ " 1000.0" ,
260+ " 1000.01" ,
261+ " 1000.001" ,
262+ " 1000.0001" ,
263+
264+ " 1000.056" ,
265+ " 1000.56" ,
266+ " 1200.56" ,
267+
268+ " 0.0001" ,
269+ " 999.99" ,
270+
271+
272+ " 9.9001" ,
273+ " 999.999" ,
274+
275+ " 99.990" ,
276+ " 99.990" ,
277+
278+ " 999.009" ,
279+
280+ " 999" ,
281+ " 999.0" ,
282+ " 999.00" ,
283+
284+ " 999.56" ,
285+
286+ };
287+
288+
289+ for (auto qStrV: qStrListV) {
290+
291+ qDebug () << " -_-_-_\n " ;
292+ qDebug () << " qDebug qStrV: " << qStrV;
293+
294+
295+ float fv = qStrV.toFloat (&bOk);
296+
297+ qDebug () << " qDebug fv #1: " << fv;
298+
299+ double double_micmacStep_forOutJson = 1.0 ;
300+ floatToDoubleWithReducedPrecision (static_cast <double >(fv), 4 , double_micmacStep_forOutJson);
301+
302+ // cout << "cout fv: " << fv;
303+ qDebug () << " qDebug fv #2: " << fv;
304+
305+ }
306+ }
307+
308+
232309bool test_precision_micmacStep_spatialResolution_values () {
233310
234311 QVector<double > qvectDoubleToTest_mustPass = {
0 commit comments