# Apple Game Frameworks and Technologies: Calculate Speed, why divide by 255? (pg. 50)

**URL:** <https://forum.devtalk.com/t/apple-game-frameworks-and-technologies-calculate-speed-why-divide-by-255-pg-50/9028>\
**Category:** PragProg Customers\
**Tags:** book-apple-game-frameworks-and-technologies, question\
**Created:** [23 April 2021 16:02 UTC](https://forum.devtalk.com/t/apple-game-frameworks-and-technologies-calculate-speed-why-divide-by-255-pg-50/9028 "2021-04-23T16:02:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahoneybellevue](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/m/b77776/32.png) [@mahoneybellevue](https://forum.devtalk.com/u/mahoneybellevue)\
**Post date:** [23 April 2021 16:02 UTC](https://forum.devtalk.com/t/apple-game-frameworks-and-technologies-calculate-speed-why-divide-by-255-pg-50/9028/1 "2021-04-23T16:02:58Z")

</div>

@Paradox927 - Just curious to know how you came up with 255 when calculating the speed, on page 60 in the PDF.

```auto
...
    let calculatedSpeed = TimeInterval(distance / playerSpeed) / 255
...

```

The code notes, and footnotes are great for illuminating the programmatic choices made, but the `255` number seems arbitrary without any immediate insight into the choice, and likely something that can be dynamically changed.

Anyways, any insight provided would be great, and thanks in advance!

---

<div class="post-metadata">

**Author:** ![Paradox927](https://forum.devtalk.com/user_avatar/forum.devtalk.com/paradox927/32/2978_2.png) [@Paradox927](https://forum.devtalk.com/u/Paradox927)\
**Post date:** [28 April 2021 12:59 UTC](https://forum.devtalk.com/t/apple-game-frameworks-and-technologies-calculate-speed-why-divide-by-255-pg-50/9028/2 "2021-04-28T12:59:27Z")

</div>

Great question!

The `255` was a somewhat arbitrary number based on how the movement speed “felt” during gameplay.

I suppose I could have used a dynamic number—for example, `Double(frame.size.width)` or something along those lines—but in this case, it didn’t much matter, so I went with a hard-coded number instead.

---

<div class="post-metadata">

**Author:** ![mahoneybellevue](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/m/b77776/32.png) [@mahoneybellevue](https://forum.devtalk.com/u/mahoneybellevue)\
**Post date:** [29 April 2021 00:32 UTC](https://forum.devtalk.com/t/apple-game-frameworks-and-technologies-calculate-speed-why-divide-by-255-pg-50/9028/3 "2021-04-29T00:32:34Z")

</div>

Arbitrary is good! lol

So much of what we do ends up tailored to the User eXperience, and sussing out an elegant math solution - though fun in its own right - is typically less relevant or necessary, and often less expedient than just getting it to market. 🙂

Thanks of taking the time to answer, and I’m really enjoying the book!
