A alexander1984 New Member Licensed User Longtime User Nov 15, 2016 #1 I have a Case Study in making a shiftleft - shiftright a long variable, I use to perform the shift left or right the "bit.shiftleft function (int x1, int x2)", but it seems not work 'cause I always result in a negative value variaible of the results. I supposed that it's 'cause int type is too many "short", i need to use an unsigned 4 byte number. Does it exist a library for shiftleft/right on long type?
I have a Case Study in making a shiftleft - shiftright a long variable, I use to perform the shift left or right the "bit.shiftleft function (int x1, int x2)", but it seems not work 'cause I always result in a negative value variaible of the results. I supposed that it's 'cause int type is too many "short", i need to use an unsigned 4 byte number. Does it exist a library for shiftleft/right on long type?
Erel B4X founder Staff member Licensed User Longtime User Nov 15, 2016 #2 You can use inline java for this: Code: Copy Sub Activity_Create(FirstTime As Boolean) Dim jo As JavaObject jo.InitializeContext Log(jo.RunMethod("ShiftLeft", Array(DateTime.Now, 2))) End Sub #If JAVA public long ShiftLeft(long N, Integer Shift) { return N << Shift; } #End If Upvote 0
You can use inline java for this: Code: Copy Sub Activity_Create(FirstTime As Boolean) Dim jo As JavaObject jo.InitializeContext Log(jo.RunMethod("ShiftLeft", Array(DateTime.Now, 2))) End Sub #If JAVA public long ShiftLeft(long N, Integer Shift) { return N << Shift; } #End If