Sub Process_Globals
End Sub
Sub Globals
Dim x As Double : x=16225.225
Dim y As Double
End Sub
Sub Activity_Create(FirstTime As Boolean)
y = cRound(x,2)
Log("Round: " & y)
End Sub
Sub cRound (Value As Double, decimal As Byte) As Double
decimal = Power(10,decimal) ' Power = 10^decimal
Value = (Value * decimal) + 0.5
Dim sma As String
sma = Value
If sma.IndexOf(".") <> -1 Then
sma = sma.SubString2(0,sma.IndexOf("."))
End If
Value = sma / 100
Return Value
End Sub
Is it for prices or currencies?Hello, have the next number: 16552.225
When apply Round2(number, 2) the result is: 16552.22
But i need that return 16552.23 like Excel.
What function i must use.
Thanks for your help.
You can try this:
B4X:Sub Process_Globals End Sub Sub Globals Dim x As Double : x=16225.225 Dim y As Double End Sub Sub Activity_Create(FirstTime As Boolean) y = cRound(x,2) Log("Round: " & y) End Sub Sub cRound (Value As Double, decimal As Byte) As Double decimal = Power(10,decimal) ' Power = 10^decimal Value = (Value * decimal) + 0.5 Dim sma As String sma = Value If sma.IndexOf(".") <> -1 Then sma = sma.SubString2(0,sma.IndexOf(".")) End If Value = sma / 100 Return Value End Sub