# Using Winston corrupts BigInts?

**URL:** <https://discourse.julialang.org/t/using-winston-corrupts-bigints/76077>\
**Category:** General Usage\
**Created:** [February 9, 2022, 1:29pm UTC](https://discourse.julialang.org/t/using-winston-corrupts-bigints/76077 "2022-02-09T13:29:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![harven](https://avatars.discourse-cdn.com/v4/letter/h/3da27b/32.png) [@harven](https://discourse.julialang.org/u/harven)\
**Post date:** [February 9, 2022, 1:29pm UTC](https://discourse.julialang.org/t/using-winston-corrupts-bigints/76077/1 "2022-02-09T13:29:58Z")

</div>

The following weird behavior appears with julia 1.7.1 and Winston v0.15.2

```
julia> big(1//2)
1//2

```

```julia
julia> using Winston
Gtk-Message: 14:17:40.676: Failed to load module "canberra-gtk-module"
Gtk-Message: 14:17:40.677: Failed to load module "canberra-gtk-module"

julia> big(1//2)
0//0

```

I [reported this weird behavior](https://github.com/JuliaGraphics/Winston.jl/issues/311) on the Winston bug tracker but I don’t expect it to be fixed there since similar bugs have been already reported and remain open.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [February 9, 2022, 1:55pm UTC](https://discourse.julialang.org/t/using-winston-corrupts-bigints/76077/2 "2022-02-09T13:55:04Z")

</div>

That looks like memory corruption.

---

<div class="post-metadata">

**Author:** ![hckr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hckr/32/4836_2.png) [@hckr](https://discourse.julialang.org/u/hckr)\
**Post date:** [February 9, 2022, 2:01pm UTC](https://discourse.julialang.org/t/using-winston-corrupts-bigints/76077/3 "2022-02-09T14:01:16Z")

</div>

It does not seem to be about `Rational`s rather than just `BigInt`.

```julia
julia> using Winston
julia> big(1)
0
julia> big(1) + big(2) == 3
true

julia> big(1) + big(2) == 2
false

julia> big(1) + big(2)
0

```

The problem seems to be about Winston.jl messing with `show`/`display` for `BigInt`s.

---

<div class="post-metadata">

**Author:** ![hckr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hckr/32/4836_2.png) [@hckr](https://discourse.julialang.org/u/hckr)\
**Post date:** [February 9, 2022, 2:58pm UTC](https://discourse.julialang.org/t/using-winston-corrupts-bigints/76077/4 "2022-02-09T14:58:32Z")

</div>

I think this is about `Base.range`, extended by Winston.jl.

In the line winston.jl:495,

```julia
range(a::Real, b::Real) = (a <= b) ? (ceil(Int, a):floor(Int, b)) :
                                     (floor(Int, a):-1:ceil(Int, b))

```

This breaks the behavior for `BigInt`s since `BigInt` is a `Real`. This extended version is called, which is incorrect for `BigInt`.

I do not know why Winston.jl extends `range` in such a way. At least, what can be done is to limit the `Real` parameters to `Union{AbstractFloat, AbstractIrrational, Rational}`.
