Yes, in VB there is the possibility to write the division using the slash or backslash character. Using the backslash, the whole result would be returned, discarding the remainder.
Yes, in VB there is the possibility to write the division using the slash or backslash character. Using the backslash, the whole result would be returned, discarding the remainder.
It's called floor division. Here is the tested code:
B4X:
Dim x As Int
Dim y As Int = 2
Dim result As Int
For x=1 To 20
result = Floor(x / y) ' Perform division and discard the fractional part
Log($"${x}->${result}"$) ' Outputs: Result
Next
I know this might be a little crazy but when having to do money math and want the remainder I would use longs or ints and multiple the number by 100
Dim Value1 As Int = 1300 ' $13.00
Dim Value2 As Int = 2
Dim Value3 As Int = Value1 / Value2
Dim Value4 As Int = Value3 / 100
Dim Value5 As Int = Value3 - (Value4 * 100)