Android Question B4XTable unable to show large numbers (>2147483647) of Long type

toby

Well-Known Member
Licensed User
Longtime User
If the column type is NUMBERS, It can only handle Int data range (max 2147483647). To prove that, try to show a Long value of 2147483648 (2147483647+1) and what you would see is "Overflow" instead. My workaround: change column type from NUMBERS to TEXT.

Did I miss anything?
 

Mahares

Expert
Licensed User
Longtime User
Did I miss anything?
If you check in Wikipedia the significance of the number, you will see this:
The number 2,147,483,647 (or hexadecimal 7FFFFFFF16) is the maximum positive value for a 32-bit signed binary integer in computing. It is therefore the maximum value for variables declared as integers (e.g., as int ) in many programming languages, and the maximum possible score, money, etc.

And, if you check the class module for B4XTable, you will see that for data definition in B4XTable is COLUMN_TYPE_NUMBERS is stored in the in-memory database table as INTEGER. That is why you hit a wall. Make it COLUMN_TYPE_TEXT as you already found out and it will show the numbers above that magic number instead of Overflow. I am sure Erel will chime in and offer more insight.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
you will see that for data definition in B4XTable is COLUMN_TYPE_NUMBERS is stored in the in-memory database table as INTEGER.
But SQLite INTEGER can hold 8 bytes of data.
I think the problem could be in B4XTableColumn.Formatter.FormatLabel.

EDIT: Yes, the problem is the B4XFormatter, in which:
B4X:
Public Const MAX_VALUE = 0x7fffffff, MIN_VALUE = 0x80000000 As Int
 
Last edited:
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Refresher.

1620511569651.png



Enjoy...
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I tend to agree Luca with your assessment here:
I think it is the B4XFormatter. If you look at the class module in B4XFormatter, there is a sub that starts like this:
B4X:
Public Sub Format (Number As Double) As String
    If Number < MIN_VALUE Or Number > MAX_VALUE Then Return "OVERFLOW"
That's prcisely what @toby has displayed when the number exceeded the max.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I tend to agree Luca with your assessment here:
I think it is the B4XFormatter. If you look at the class module in B4XFormatter, there is a sub that starts like this:
B4X:
Public Sub Format (Number As Double) As String
    If Number < MIN_VALUE Or Number > MAX_VALUE Then Return "OVERFLOW"
That's prcisely what @toby has displayed when the number exceeded the max.
Yes, I saw that and only then I searched for MAX_VALUE ;)
 
Upvote 0
Top