# There is a possibility to \`DivideError\` without a denominator value of 0

**URL:** <https://discourse.julialang.org/t/there-is-a-possibility-to-divideerror-without-a-denominator-value-of-0/75832>\
**Category:** New to Julia\
**Created:** [February 5, 2022, 12:02am UTC](https://discourse.julialang.org/t/there-is-a-possibility-to-divideerror-without-a-denominator-value-of-0/75832 "2022-02-05T00:02:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmsmsgood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rmsmsgood/32/20544_2.png) [@rmsmsgood](https://discourse.julialang.org/u/rmsmsgood)\
**Post date:** [February 5, 2022, 12:02am UTC](https://discourse.julialang.org/t/there-is-a-possibility-to-divideerror-without-a-denominator-value-of-0/75832/1 "2022-02-05T00:02:43Z")

</div>

I’m sorry to ask this without specific cases(i can’t find that), but our team guess that the following code raise the `DivideError`.

```julia
    while y != zero(R)
        q = div(x, y)
        x, y = y, x - y * q
        s0, s1 = s1, s0 - q * s1
        t0, t1 = t1, t0 - q * t1
    end

```

The `while` guarantees that `y` is nonzero hence `div` must work properly, but error occurs. Anybody has a clue?

ps. One coworker guessed that the large integers may be a suspect. Is it possible? If then, how we overcome this issue? `BigInt`?

ps2. I just found a case!

```julia
julia> div(-9223372036854775808,-1)
ERROR: LoadError: DivideError: integer division error
Stacktrace:
 [1] div(x::Int64, y::Int64)
   @ Base .\int.jl:284

```

Is this overflow issue?

```julia
julia> typemax(Int64)
9223372036854775807

julia> -9223372036854775808
-9223372036854775808

```

---

<div class="post-metadata">

**Author:** ![blackeneth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blackeneth/32/10353_2.png) [@blackeneth](https://discourse.julialang.org/u/blackeneth)\
**Post date:** [February 5, 2022, 2:55am UTC](https://discourse.julialang.org/t/there-is-a-possibility-to-divideerror-without-a-denominator-value-of-0/75832/2 "2022-02-05T02:55:13Z")

</div>

What is R? What type is it?

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [February 5, 2022, 3:04am UTC](https://discourse.julialang.org/t/there-is-a-possibility-to-divideerror-without-a-denominator-value-of-0/75832/3 "2022-02-05T03:04:57Z")

</div>

> [@rmsmsgood](#):
>
> Is this overflow issue?

Probably, yeah. Note that the max and min values of a signed integer differ by one:

```julia
julia> typemin(Int8)
-128

julia> typemax(Int8)
127

```

due to the [two’s complement](https://en.wikipedia.org/wiki/Two%27s_complement) representation.
