B4J Question isNumber("1f") =>> TRUE !!

Tayfur

Well-Known Member
Licensed User
Longtime User
I looked a n interesting result with "isnumber" function.
"1f" and "1d" returned TRUE !!!!
why?

B4X:
If IsNumber("1f") Then Log("f")' return f
If IsNumber("ff") Then Log("a")'------
If IsNumber("1ff") Then Log("a")'------
If IsNumber("1f1") Then Log("a")'------
        If IsNumber("1e") Then Log("e")'------
        If IsNumber("1d ") Then Log("d") ' return d
        If IsNumber("1c") Then Log("c")'------
        If IsNumber("1b") Then Log("b")'------
        If IsNumber("1a") Then Log("a")'------
 

Tayfur

Well-Known Member
Licensed User
Longtime User
Upvote 0

moster67

Expert
Licensed User
Longtime User
Try something like this:
B4X:
Dim x As String = "1d"
 
    If IsNumber(x) Then
        Log("is number")
        'double-check
        If x.EndsWith("D") Or x.EndsWith("d") Or x.EndsWith("F") Or x.EndsWith("f") Or x.EndsWith("L") Or x.EndsWith("l") Then
            Log("not a number")
        End If
    Else
       'no number
    End If

Also "L" or "l" can be used in Java to indicate long (normally capital letter "L" is used since the non capital letter "l" can be confused with the number one (1)

There may be better solutions...
 
Upvote 0
Top