Hi,
As far as I know, Xojo doesn’t have any native functions for rounding like VB6 “Round”.
So I have to resort to Format but I don’t like it because ti changes to type to strings and it won’t work with negative numbers.
So what do you guys use to round decimals ? Did you have to build your own function ^?
thanks
all these functions (ceiling, floor, round) return an interger, I need to round to 2 decimals for example.
there are no native functions that do this… what are your alternatives ^
Maybe he is confused by Floor/Ceiling, at first this looks weird, and I was bitten by it in the past:
Var a, b, c, d As Double
a = Floor(4.5) // 4
b = Ceiling(4.5) // 5
c = Floor(-4.5) // -5
d = Ceiling(-4.5) // -4
break
a = Floor(4.4) // 4
b = Ceiling(4.4) // 5
c = Floor(-4.4) // -5
d = Ceiling(-4.4) // -4
break
a = Floor(4.0) // 4
b = Ceiling(4.0) // 4
c = Floor(-4.0) // -4
d = Ceiling(-4.0) // -4
break
a = Floor(4.9) // 4
b = Ceiling(4.9) // 5
c = Floor(-4.9) // -5
d = Ceiling(-4.9) // -4
break
Var a As Double = -3.1456
Var b,c As String
b = Format(a, "-#.##") // b = -3,15 // locale uses comma, and needs "-"
c = a.ToString("#.##") // c = -3.15 // US format anyway, don't need "-"
Break