For those of you who dont know what int does then it rounds a number down to it's nearest lower whole number. Could we have this as a block in Scratch?
Offline
exactly
(round((var)-(0.5)))and for round-up:
(round((var)+(0.49999999999999999)))
Offline
thebriculator wrote:
exactly
(round((var)-(0.5)))and for round-up:(round((var)+(0.49999999999999999)))
Thank you!
Offline
zammer990 wrote:
JH1010 wrote:
thebriculator wrote:
exactly
(round((var)-(0.5)))and for round-up:(round((var)+(0.49999999999999999)))Thank you!
You don't need the .99999, 5 is fine
Int only rounds down anyway.
Offline
zammer990 wrote:
JH1010 wrote:
thebriculator wrote:
exactly
(round((var)-(0.5)))and for round-up:(round((var)+(0.49999999999999999)))Thank you!
You don't need the .99999, 5 is fine
No, if var is a whole number it will add .5 and round up to the number above.
Offline
joefarebrother wrote:
zammer990 wrote:
JH1010 wrote:
Thank you!You don't need the .99999, 5 is fine
No, if var is a whole number it will add .5 and round up to the number above.
True.
Offline
A better way is to X - X mod 1, but this needs the input twice.
Offline
Yep, round up needs the .999999999
and cool, the mod technique works for "round-up"
Offline