Bug? Error with the Abs function

D

Deleted member 103

Guest
Hi,

please gaze at my code. It works up to a number and then displays an error message.
'ERROR
'main_show_log (java line: 359)
'java.lang.NumberFormatException: 1.00081E7
'...
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

    Dim Thread1 As Thread
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim args(0) As Object
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")

    Thread1.Initialise("Thread1")

    Thread1.Start(Me,"go_Thread1", args)
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub go_Thread1
    Dim vorZeichen As String =""
    Dim obj(1) As Object
   
    Dim number As Long = 9999100  'it works up to this number
   
    For number = 9710100 To 10220000 Step 1000
        obj(0) = vorZeichen & Abs(number)
   
        Thread1.RunOnGuiThread("Show_Log",obj)
    Next
End Sub

Sub Thread1_Ended(fail As Boolean, error As String) 'An error or Exception has occurred in the Thread
    Log("Thread1 Ended: fail= " & fail & " :error=" & error)
End Sub

Sub Show_Log(obj As Object)
    Dim number As Long = obj
   
    Log(number)
End Sub
 
D

Deleted member 103

Guest
Here is the log file:
** Activity (main) Create, isFirst = true **


** Activity (main) Resume **


9840100


9840100


9840100
9840100
9840100
9840100
9840100
9840100
9840100
9840100


9840100
9840100
9840100
9840100
9840100
9840100
9840100
9840100
9840100
9840100
9840100
9840100
9850100
9850100
9850100
9850100
9850100
9850100
9850100
9850100
9850100
9850100
9850100
9850100
9850100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100


9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9878100
9888100


9888100
9888100
9888100
9888100
9888100
9888100
9888100
9888100
9888100


9888100
9888100
9888100
9888100
9888100
9900100
9900100
9900100
9900100
9900100
9900100
9900100
9900100
9900100
9900100
9900100
9900100
9900100


9900100
9912100


9912100
9912100
9912100
9912100
9912100
9912100
9912100
9912100
9912100
9912100
9912100
9912100
9914100


9925100
9925100
9925100
9925100
9925100
9925100
9925100
9925100
9925100
9925100
9925100
9925100
9935100
9935100
9935100
9935100
9935100
9935100
9935100


9935100
9935100
9935100
9935100
9935100
9935100
9935100
9947100
9947100
9947100
9947100
9947100
9947100
9947100
9947100
9947100
9947100
9947100
9947100
9947100
9947100
9947100
9947100
9961100
9961100
9961100
9961100
9961100
9961100
9961100
9961100
9961100
9961100
9961100
9961100
9961100
9961100


9974100
9974100
9974100
9974100
9974100
9974100
9974100
9974100
9974100
9974100
9975100
9975100
9975100
9975100
9975100
9975100
9975100
9985100
9985100
9985100
9985100
9985100
9985100
9985100
9985100
9985100
9985100
9985100
9985100
9985100
9985100
9985100
9995100
9995100
9995100
9995100
9995100
9995100
9995100
9995100


9995100
9995100
9995100
main_show_log (java line: 359)
java.lang.NumberFormatException: 1.00011E7
at java.lang.Long.parse(Long.java:364)
at java.lang.Long.parseLong(Long.java:354)
at java.lang.Long.parseLong(Long.java:320)
at anywheresoftware.b4a.BA.ObjectToLongNumber(BA.java:587)
at b4a.example.main._show_log(main.java:359)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA$3.run(BA.java:312)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NumberFormatException: 1.00011E7
 

Attachments

  • test_abs.zip
    6.1 KB · Views: 204
D

Deleted member 103

Guest
It is clear to me that you can do so, but I have to perform the conversion in my app as a String.
The question is why does to 9995100?
 
Top