# \[ANN\] SaferIntegers for v0.7 with \`^\`

**URL:** https://discourse.julialang.org/t/ann-saferintegers-for-v0-7-with/11713
**Category:** Community
**Created:** [June 16, 2018, 5:49am UTC](https://discourse.julialang.org/t/ann-saferintegers-for-v0-7-with/11713 "2018-06-16T05:49:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)
#### Post date: [June 16, 2018, 5:49am UTC](https://discourse.julialang.org/t/ann-saferintegers-for-v0-7-with/11713/1 "2018-06-16T05:49:39Z")

</div>

The latest release of [SaferIntegers](https://github.com/JeffreySarnoff/SaferIntegers.jl) supports v0.7- (use an earlier release with v0.6). This release introduces a safe `^` that is very fast for bases 2:64. More tests have been added.

SaferIntegers.jl exports `SafeInt64`, `SafeInt32`, `SafeUInt64` …, types that are as Int and UInt types except that arithmetic overflow throws an OverflowError. These types allow you to work with integers knowing there is no silent wrap-around or other mistake being used.

Please see the [README](https://github.com/JeffreySarnoff/SaferIntegers.jl/blob/master/README.md) for more information.

---

<div class="post-metadata">

### Author: ![Jean\_Michel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jean_michel/32/8282_2.png) [@Jean\_Michel](https://discourse.julialang.org/u/Jean_Michel)
#### Post date: [February 4, 2019, 12:07am UTC](https://discourse.julialang.org/t/ann-saferintegers-for-v0-7-with/11713/2 "2019-02-04T00:07:38Z")

</div>

Hello, I like `SafeInts`. Recently I wanted to use them for `Rational`s, but there are some small problems:

```julia
julia> using SaferIntegers

julia> a=SafeInt(6)
6

julia> b=SafeInt(8)
8

julia> c=a//b
ERROR: checked_abs not defined for SafeInt64
Stacktrace:
 [1] error(::String, ::String, ::Type) at ./error.jl:42
 [2] no_op_err(::String, ::Type) at ./promotion.jl:388
 [3] checked_abs(::SafeInt64) at ./checked.jl:30
 [4] gcd(::SafeInt64, ::SafeInt64) at ./intfuncs.jl:25
 [5] divgcd(::SafeInt64, ::SafeInt64) at ./rational.jl:25
 [6] Rational{SafeInt64}(::SafeInt64, ::SafeInt64) at ./rational.jl:14
 [7] Rational(::SafeInt64, ::SafeInt64) at ./rational.jl:20
 [8] //(::SafeInt64, ::SafeInt64) at ./rational.jl:43
 [9] top-level scope at none:0

```

you can get around this error by

```julia
julia> Base.checked_abs(a::SafeInt)=abs(a)

julia> c=a//b
3//4

```

but there are further problems

```julia
julia> c+c
ERROR: MethodError: no method matching mul_with_overflow(::SafeInt64, ::SafeInt64)
Stacktrace:
 [1] checked_mul at ./checked.jl:287 [inlined]
 [2] +(::Rational{SafeInt64}, ::Rational{SafeInt64}) at ./rational.jl:253
 [3] top-level scope at none:0

```

could you have a look at it?  
Thanks in advance…

---

<div class="post-metadata">

### Author: ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)
#### Post date: [February 4, 2019, 2:57pm UTC](https://discourse.julialang.org/t/ann-saferintegers-for-v0-7-with/11713/3 "2019-02-04T14:57:04Z")

</div>

Thank you for the heads up. I had not been supporting Rationals. Looking into it.

---

<div class="post-metadata">

### Author: ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)
#### Post date: [February 4, 2019, 8:36pm UTC](https://discourse.julialang.org/t/ann-saferintegers-for-v0-7-with/11713/4 "2019-02-04T20:36:11Z")

</div>

SaferIntegers v0.3.0 supports Rational{SI} where SI\<:SafeInteger.

---

<div class="post-metadata">

### Author: ![Jean\_Michel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jean_michel/32/8282_2.png) [@Jean\_Michel](https://discourse.julialang.org/u/Jean_Michel)
#### Post date: [February 4, 2019, 9:41pm UTC](https://discourse.julialang.org/t/ann-saferintegers-for-v0-7-with/11713/5 "2019-02-04T21:41:32Z")

</div>

Thanks a lot! I wanted to check the correctness of a computation using a big rational matrix. Using SafeInts  
slows down the computation by 10%, compared to Ints, while using BigInts slows it by a factor of 27!
