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?

Code: Copy
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")'------
 
Upvote 0
Try something like this:
Code: Copy
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
Back
Top