# Random Velocity Decimals

**URL:** <https://forum.code.org/t/random-velocity-decimals/32304>\
**Category:** CS Discoveries\
**Tags:** csd-unit-3\
**Created:** [February 22, 2020, 9:55pm UTC](https://forum.code.org/t/random-velocity-decimals/32304 "2020-02-22T21:55:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sam.barnhart](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@sam.barnhart](https://forum.code.org/u/sam.barnhart)\
**Post date:** [February 22, 2020, 9:55pm UTC](https://forum.code.org/t/random-velocity-decimals/32304/1 "2020-02-22T21:55:40Z")

</div>

We are creating games to finish Unit 3 of CS Discoveries. I’m having trouble creating random sprite velocities that are decimals. Looking at the debug console, it appears to round to whole numbers, including 0. So if I put a range of .1 and 2 into the random number min and max for a sprite velocity, it will sometimes go to 0, sometimes 1 & sometimes 2, but never a decimal. I then thought velocities had to be whole numbers but if I just enter .5 as a velocity that works just fine. So is there anyway to create a range of random velocities that include decimals? Thanks.

Sam

---

<div class="post-metadata">

**Author:** ![mkmietowicz](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mkmietowicz/32/6322_2.png) [@mkmietowicz](https://forum.code.org/u/mkmietowicz)\
**Post date:** [February 23, 2020, 8:13pm UTC](https://forum.code.org/t/random-velocity-decimals/32304/2 "2020-02-23T20:13:16Z")

</div>

Hi @sam.barnhart,

You’re right – randomNumber generates an integer. If you were to generate an integer between, say, 0 and 20, is there a way you could store that number and then manipulate it to get a decimal?

Let us know if you need more help with this one.

–Michael K.
