# Making the \`\`\`BigFloat\`\`\` type parametric

**URL:** https://discourse.julialang.org/t/making-the-bigfloat-type-parametric/66037
**Category:** Internals & Design
**Created:** [August 8, 2021, 6:52pm UTC](https://discourse.julialang.org/t/making-the-bigfloat-type-parametric/66037 "2021-08-08T18:52:20Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Lucas\_Queiroz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lucas_queiroz/32/12086_2.png) [@Lucas\_Queiroz](https://discourse.julialang.org/u/Lucas_Queiroz)
#### Post date: [August 8, 2021, 6:52pm UTC](https://discourse.julialang.org/t/making-the-bigfloat-type-parametric/66037/1 "2021-08-08T18:52:20Z")

</div>

Hello!

I am someone who is very enthusiastic about Julia language, and here I would like to comment about the `BigFloat` type, as well as make a proposal.

The precision of `BigFloat` depends on a global state, which you can change with `setprecision`:

```julia
julia> setprecision(2)
2

julia> BigFloat("0.3")
0.25

julia> setprecision(100)
100

julia> BigFloat("0.3")
0.30000000000000000000000000000016

```

The problem I see is that precision may be changed, without the user even being aware of.

```julia
julia> function f()
           setprecision(2)
       end
f (generic function with 1 method)

julia> function double(x)
           f()
           return 2*x
       end
double (generic function with 1 method)

julia> setprecision(100)
100

julia> double(BigFloat("0.3"))
0.50

```

In a code that is very big and uses many library functions, it might be very difficult to verify that the precision of the `BigFloat` type doesn’t change along the way.

Would it be a good idea to have a parametric type `BigFloat{n <: Int}`?

---

<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: [August 8, 2021, 7:38pm UTC](https://discourse.julialang.org/t/making-the-bigfloat-type-parametric/66037/2 "2021-08-08T19:38:42Z")

</div>

This would be a good idea but would require rewriting `BigFloat` in Julia

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [August 8, 2021, 7:39pm UTC](https://discourse.julialang.org/t/making-the-bigfloat-type-parametric/66037/3 "2021-08-08T19:39:44Z")

</div>

See this discussion in GitHub: [https://github.com/JuliaLang/julia/issues/10040](https://github.com/JuliaLang/julia/issues/10040)

---

<div class="post-metadata">

### Author: ![Lucas\_Queiroz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lucas_queiroz/32/12086_2.png) [@Lucas\_Queiroz](https://discourse.julialang.org/u/Lucas_Queiroz)
#### Post date: [August 8, 2021, 9:01pm UTC](https://discourse.julialang.org/t/making-the-bigfloat-type-parametric/66037/5 "2021-08-08T21:01:04Z")

</div>

Nice! I am reading this discussionn
