# Checked vs unchecked, e.g. (floored) divison

**URL:** <https://discourse.julialang.org/t/checked-vs-unchecked-e-g-floored-divison/122899>\
**Category:** Performance\
**Created:** [November 21, 2024, 2:32pm UTC](https://discourse.julialang.org/t/checked-vs-unchecked-e-g-floored-divison/122899 "2024-11-21T14:32:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [November 21, 2024, 4:07pm UTC](https://discourse.julialang.org/t/checked-vs-unchecked-e-g-floored-divison/122899/2 "2024-11-21T16:07:37Z")

</div>

> [@Palli](#):
>
> I.e. there is `fld` for all numbers, but ÷ (and `div`) aren’t floored, so does that matter? ÷ works for all positive numbers, and when do you actually want `fld` for the negative ones?

The advantage of mapping ÷ to `fld` is that then `%` needs to be `mod`, which is not so uncommon to use with a negative first argument. Both `rem` and `mod` give you a useful cyclic behavior for positive numbers. If you go past zero `mod` keeps being cyclic, whereas `rem` makes a sign shift and goes over to a cycle with negative numbers. I’m sure there’s some context where `rem` is useful with negative first argument, but I’m yet to find it. In my experience `mod` is always the operator you want and if you carelessly use `%` it’s an invitation for bugs.

> [@Palli](#):
>
> Python is actually the odd one out

I’m not generally enthusiastic about Python but this is something they got right, and Julia (and many other languages) sadly didn’t.

---

_[View the full topic](https://discourse.julialang.org/t/checked-vs-unchecked-e-g-floored-divison/122899)._
