i am sure i am doing something wrong but i need to get the remainder of a Float value in b4i.
Mod function in b4i expect only integers so i use Bit.FMod function but i am not getting the result as in b4j/b4a
B4X:
For i = 0 To 5
'b4a/b4j
Log((i*-360)+0.5 Mod 360)
'b4i
'Log(Bit.FMod((i*-360)+0.5,360))
Next
Result:
b4a/b4j
Waiting for debugger to connect...
Program started.
0.5
-359.5
-719.5
-1079.5
-1439.5
-1799.5
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Application_Start
0.5
-359.5
-359.5
-359.5
-359.5
-359.5
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Application_Active
Application_Inactive
Application_Background
Can't end BackgroundTask: no background task exists with identifier 1027 (0x403), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
I have a vague recollection that some BASIC dialects' modulus functions are actually remainders. Above zero they're the same; below zero they can differ.
When negative numbers are involved, I have found it simpler to roll my own. INT and FLOOR always round down.