Hi!
I don't want to annoy you. But I'm still having big problems with the 64-bit-integers in B4A.
Please try following code:
The result should be: 3891110078048108501 (you can test it in Windows-calculator).
But B4A/Java returns: 3891110078048108544 (many bits were set to 0 ?! ...:
110101111111111111111111111111111111111111111111111111110101010 = 7782220156096217002
011010111111111111111111111111111111111111111111111111111010101 = 3891110078048108501 = CORRECT (Windows-calculator)
011011000000000000000000000000000000000000000000000000000000000 = 3891110078048108544 = WRONG!!! (B4A / Java)
Does Java cannot handle 64-bit-integers? Or is it a bug in B4A (but B4A "only" translates the BASIC-syntax to Java - it does not do any calculations, right?).
The problem occurs in Debug- and Release-mode, on the emulator and on a physical device.
Normally I would say, that I'm doing something wrong, because if this is a real bug, then many people would be affected. But then I think, the code above is very short and really simple. What can I do wrong in these few lines?!
In the moment, I need the division to shift bits in a 64-Bit-Integer. But generally my trustfulness to Java is decreasing ... :-(
If you have any ideas, I am looking forward to read it. Thank you very much in advance!
Nice greetings,
Wolfgang
I don't want to annoy you. But I'm still having big problems with the 64-bit-integers in B4A.
Please try following code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim q As Long
Dim q2 As Long
Dim q3 As Long
q = 7782220156096217002
q2 = 2
q3 = q / q2
Log (q3)
Return
End Sub
The result should be: 3891110078048108501 (you can test it in Windows-calculator).
But B4A/Java returns: 3891110078048108544 (many bits were set to 0 ?! ...:
110101111111111111111111111111111111111111111111111111110101010 = 7782220156096217002
011010111111111111111111111111111111111111111111111111111010101 = 3891110078048108501 = CORRECT (Windows-calculator)
011011000000000000000000000000000000000000000000000000000000000 = 3891110078048108544 = WRONG!!! (B4A / Java)
Does Java cannot handle 64-bit-integers? Or is it a bug in B4A (but B4A "only" translates the BASIC-syntax to Java - it does not do any calculations, right?).
The problem occurs in Debug- and Release-mode, on the emulator and on a physical device.
Normally I would say, that I'm doing something wrong, because if this is a real bug, then many people would be affected. But then I think, the code above is very short and really simple. What can I do wrong in these few lines?!
In the moment, I need the division to shift bits in a 64-Bit-Integer. But generally my trustfulness to Java is decreasing ... :-(
If you have any ideas, I am looking forward to read it. Thank you very much in advance!
Nice greetings,
Wolfgang