Join the live talk at Discord.Be part of the conversation athttp://discord.qb64.org.
0 Members and 1 Guest are viewing this topic.
X = INT(X * 100 + .5) / 100 to round at 2 decimal places.
Seems unnecessarily complicated? Why not the simple:X = CINT(X * 100) / 100 to round at 2 decimal places?
X = INT(X * 100) / 100 to truncate at 2 decimal places.X = INT(X * 100 + .5) / 100 to round at 2 decimal places.
FUNCTION RoundTo## (Num AS _FLOAT, Precision AS INTEGER) RoundTo = INT(Num * 10 ^ Precision + .5) / 10 ^ PrecisionEND FUNCTION
Hi,tried the INT version ... 4/3 = 133.3333 ?? both INT solutions give me the same answeri.e. X = INT(4 * 100 + .5) / 3 orX = INT(4 * 100) / 3I would like 1.33 to 2 decimal placesand 4/6 = 1.67 and this roundedI have tried the string manipulations and it seems to work fine.Mike