I have encountered a strange problem while asigning a value to a variable of type long. To reproduce, create a default project and use this code:
Now run it and this is the log output:
The last value is wrong, and I have no idea why this happens. I came across this when processing sqlite records to check their age, so I want records older than 30 days to be marked as stale.
30 days = 30*24*60*60*1000 in milliseconds.
I noticed that 2592000000 = 0000 0000 9A7E C800 in HEX, and -1702967296 = FFFF FFFF 9A7E C800
What am I doing wrong?
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
Dim ltest As Long
ltest = 2592000000
Log(ltest)
ltest = 30*24*60*60
Log(ltest)
ltest = ltest * 1000
Log(ltest)
ltest = 30*24*60*60*1000
Log(ltest)
End Sub
Now run it and this is the log output:
B4X:
--------- beginning of main
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
2592000000
2592000
2592000000
-1702967296
** Activity (main) Resume **
The last value is wrong, and I have no idea why this happens. I came across this when processing sqlite records to check their age, so I want records older than 30 days to be marked as stale.
30 days = 30*24*60*60*1000 in milliseconds.
I noticed that 2592000000 = 0000 0000 9A7E C800 in HEX, and -1702967296 = FFFF FFFF 9A7E C800
What am I doing wrong?