# Division by Zero

**URL:** <https://forum.crystal-lang.org/t/division-by-zero/8483>\
**Category:** Help & Support\
**Created:** [October 15, 2025, 12:16pm UTC](https://forum.crystal-lang.org/t/division-by-zero/8483 "2025-10-15T12:16:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joerg](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@Joerg](https://forum.crystal-lang.org/u/Joerg)\
**Post date:** [October 15, 2025, 12:16pm UTC](https://forum.crystal-lang.org/t/division-by-zero/8483/1 "2025-10-15T12:16:50Z")

</div>

def div  
begin  
x = 20 / 0 # 10  
rescue  
pp "Division durch NULL ! "  
end  
end

x = div  
pp x.to\_s

Hi,

I have this little Program. I don’t understand why the rescue don’t work.

Compiling is ok.

Output for 20 / 10 is ok

Output for 20 / 0 is Infinity but not the pp “…”

Why?

(Sorry for my English)

---

<div class="post-metadata">

**Author:** ![HertzDevil](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hertzdevil/32/1023_2.png) [@HertzDevil](https://forum.crystal-lang.org/u/HertzDevil)\
**Post date:** [October 15, 2025, 12:44pm UTC](https://forum.crystal-lang.org/t/division-by-zero/8483/2 "2025-10-15T12:44:57Z")

</div>

`/` is the float division and, under most circumstances, division by zero is fine for IEEE 754 floats. The integer division operator is `//` and will raise `DivisionByZeroError`.
