M Mauricio Pereira Member Licensed User Longtime User Jun 16, 2020 #1 The following error appears in the simple attached program: Error occurred on line: 39 (Main) java.lang.NumberFormatException: Invalid double: "2,000.88" at java.lang.StringToReal.invalidReal(StringToReal.java:63) at java.lang.StringToReal.initialParse(StringToReal.java:164) at java.lang.StringToReal.parseDouble(StringToReal.java:282) ...... Why ?? Attachments Test.zip Test.zip 74.8 KB · Views: 319
The following error appears in the simple attached program: Error occurred on line: 39 (Main) java.lang.NumberFormatException: Invalid double: "2,000.88" at java.lang.StringToReal.invalidReal(StringToReal.java:63) at java.lang.StringToReal.initialParse(StringToReal.java:164) at java.lang.StringToReal.parseDouble(StringToReal.java:282) ...... Why ??
agraham Expert Licensed User Longtime User Jun 16, 2020 #2 From the error it probably doesn't like the comma thousands separator. Upvote 0
DonManfred Expert Licensed User Longtime User Jun 16, 2020 #3 Mauricio Pereira said: Why ?? Click to expand... You are using a Formatted Double (x) to check if the value is greater than 999. Do such tests on the Double. B4X: Copy If A > 999 Then Log(X) Else Log(X) End If Upvote 0
Mauricio Pereira said: Why ?? Click to expand... You are using a Formatted Double (x) to check if the value is greater than 999. Do such tests on the Double. B4X: Copy If A > 999 Then Log(X) Else Log(X) End If
M Mauricio Pereira Member Licensed User Longtime User Jun 16, 2020 #4 Agraham, but who puts the comma ?? Upvote 0
DonManfred Expert Licensed User Longtime User Jun 16, 2020 #5 Mauricio Pereira said: but who puts the comma ?? Click to expand... B4X: Copy X = formatter.Format(A) Upvote 0
Mauricio Pereira said: but who puts the comma ?? Click to expand... B4X: Copy X = formatter.Format(A)
M Mauricio Pereira Member Licensed User Longtime User Jun 16, 2020 #6 DonManfred, The problem is with the formatter... If we use X = NumberFormat2 (A, 1,2,0, False) it works! Upvote 0
DonManfred, The problem is with the formatter... If we use X = NumberFormat2 (A, 1,2,0, False) it works!
agraham Expert Licensed User Longtime User Jun 16, 2020 #7 DonManfred said: Do such tests on the Double. Click to expand... As DonManfred said. Test the Double value directly - don't format it into a String. Upvote 0
DonManfred said: Do such tests on the Double. Click to expand... As DonManfred said. Test the Double value directly - don't format it into a String.