B4J Question error with small numbers using b4xeval

jjarrell

New Member
Licensed User
When the numbers are smaller than 3 decimal places in parenthesis b4xeval appears to treat it as a string instead of a number causing it to error.

Any ideas?

B4X:
    Dim e As B4XEval
    e.Initialize(Me, "Eval")

    Log((.03+.02)/2)
    Log(e.Eval("(.03+.02)/2"))
    
    Log((.003+.002)/2)
    Log(e.Eval("(.003+.002)/2"))
    
    Log((.0003+.0002)/2)
    Log(e.Eval("(.0003+.0002)/2"))
Results in log:

0.025
0.025
0.0025
0.0025
2.5E-4
b4xeval._vv2 (java line: 268)
java.lang.NumberFormatException: For input string: "null"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at anywheresoftware.b4a.BA.ObjectToNumber(BA.java:395)
at b4j.example.b4xeval._vv2(b4xeval.java:268)
at b4j.example.b4xeval._vv1(b4xeval.java:206)
at b4j.example.main._appstart(main.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.main(main.java:28)
 
Top