# ANN: BitIntegers.jl (Int256, ...) and BitFloats.jl (Float80, Float128)

**URL:** <https://discourse.julialang.org/t/ann-bitintegers-jl-int256-and-bitfloats-jl-float80-float128/15935>\
**Category:** Community\
**Tags:** package, announcement\
**Created:** [October 5, 2018, 5:25pm UTC](https://discourse.julialang.org/t/ann-bitintegers-jl-int256-and-bitfloats-jl-float80-float128/15935 "2018-10-05T17:25:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [October 5, 2018, 5:25pm UTC](https://discourse.julialang.org/t/ann-bitintegers-jl-int256-and-bitfloats-jl-float80-float128/15935/1 "2018-10-05T17:25:07Z")

</div>

I’m glad to present two new registered packages which add more “native-like” types to Julia, mostly implemented in the same way as `Base` builtin integer and floating point types.

Both packages can lead to segfaults that I don’t understand, and they are under-tested, so they must be considered as experimental; other contributors will be needed to overcome the shortcomings (read the respective READMEs for more information).  
That said, they can already be useful 😃

[BitIntegers.jl](https://github.com/rfourquet/BitIntegers.jl) exports signed and unsiged integer types of size 256, 512 and 1024 bits, but any other size (multiple of 8 bits) can be created easily via a macro.  
The main unimplemented features are division operations, for which intrinsics (LLVM builtin) don’t work, at least on my machine. So this is currently done via conversion to/from `BigInt`, which is very slow.

[BitFloats.jl](https://github.com/rfourquet/BitFloats.jl) simply wraps two floating-point types exposed by LLVM:

- `Float80` is apparently not available on all machines, but it works OK on mine. The outstanding issue is that currently creating arrays of them lead easily to segfaults (this is a [bug in julia](https://github.com/JuliaLang/julia/issues/29053) which should go away reasonably soon)
- `Float128` is quite slow for most operations: LLVM doesn’t implement those (on my machine), so conversion to/from `BigFloat` is done.

Overall I was amazed that these builtin-like types could be implemented in packages, with relatively few lines of codes; but there is a lot of duplication with `Base` code; I would be happy to contribute to a refactoring effort in order to reduce duplication.

Again, these packages are at a very experimental stage, and could be seen as only a proof of concept; in particular, it’s not clear that `BitFloats.jl` can ever reach maturity, but it may help in the development of other solutions.

Happy hacking!

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [October 5, 2018, 6:00pm UTC](https://discourse.julialang.org/t/ann-bitintegers-jl-int256-and-bitfloats-jl-float80-float128/15935/2 "2018-10-05T18:00:20Z")

</div>

Fantastic work! Most of what DiffEq needs are these Float80 and Float128 types, so I am happy to see work in this area.

---

<div class="post-metadata">

**Author:** ![Alexey\_Goldin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexey_goldin/32/14379_2.png) [@Alexey\_Goldin](https://discourse.julialang.org/u/Alexey_Goldin)\
**Post date:** [January 24, 2022, 7:02pm UTC](https://discourse.julialang.org/t/ann-bitintegers-jl-int256-and-bitfloats-jl-float80-float128/15935/3 "2022-01-24T19:02:51Z")

</div>

Any recent work on Float80?

Just tried it with Julia 1.7.1. Adding/multiplication/subtraction/division work, but anything as simple as sqrt(Float80(1)) results in

Module IR does not contain specified entry function

Stacktrace:  
[1] sqrt(x::Float80)  
@ BitFloats ~/.julia/packages/BitFloats/qTO7E/src/BitFloats.jl:590  
[2] top-level scope  
@ In[29]:1  
[3] eval  
@ ./boot.jl:373 [inlined]  
[4] include\_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)  
@ Base ./loading.jl:1196

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [January 24, 2022, 7:22pm UTC](https://discourse.julialang.org/t/ann-bitintegers-jl-int256-and-bitfloats-jl-float80-float128/15935/4 "2022-01-24T19:22:59Z")

</div>

If you want higher precision Floats, I would recommend `DoubleFloats`

---

<div class="post-metadata">

**Author:** ![Alexey\_Goldin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexey_goldin/32/14379_2.png) [@Alexey\_Goldin](https://discourse.julialang.org/u/Alexey_Goldin)\
**Post date:** [January 24, 2022, 7:41pm UTC](https://discourse.julialang.org/t/ann-bitintegers-jl-int256-and-bitfloats-jl-float80-float128/15935/5 "2022-01-24T19:41:36Z")

</div>

Thx. Are they any faster than Quadmath?

I hoped that hardware supported Float80 can be faster than Float128.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [January 24, 2022, 7:46pm UTC](https://discourse.julialang.org/t/ann-bitintegers-jl-int256-and-bitfloats-jl-float80-float128/15935/6 "2022-01-24T19:46:23Z")

</div>

According to [https://github.com/JuliaMath/DoubleFloats.jl](https://github.com/JuliaMath/DoubleFloats.jl), it’s very roughly 2-10x faster than Quadmath. `Float80` would b e faster, but I’m not sure how much.

---

<div class="post-metadata">

**Author:** ![Alexey\_Goldin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexey_goldin/32/14379_2.png) [@Alexey\_Goldin](https://discourse.julialang.org/u/Alexey_Goldin)\
**Post date:** [January 24, 2022, 7:51pm UTC](https://discourse.julialang.org/t/ann-bitintegers-jl-int256-and-bitfloats-jl-float80-float128/15935/7 "2022-01-24T19:51:23Z")

</div>

Thanks, this is great.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [January 24, 2022, 7:54pm UTC](https://discourse.julialang.org/t/ann-bitintegers-jl-int256-and-bitfloats-jl-float80-float128/15935/8 "2022-01-24T19:54:34Z")

</div>

Also `exp` and `log` for it will soonish get significantly faster ([https://github.com/JuliaMath/DoubleFloats.jl/pull/136](https://github.com/JuliaMath/DoubleFloats.jl/pull/136))

---

<div class="post-metadata">

**Author:** ![Alexey\_Goldin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexey_goldin/32/14379_2.png) [@Alexey\_Goldin](https://discourse.julialang.org/u/Alexey_Goldin)\
**Post date:** [January 24, 2022, 8:22pm UTC](https://discourse.julialang.org/t/ann-bitintegers-jl-int256-and-bitfloats-jl-float80-float128/15935/9 "2022-01-24T20:22:04Z")

</div>

(So far looks like about 1.5 times faster than QuadMath on the ODE I am trying it for). Thanks again!
