# Computation with huge numbers: BigInt, BigFloat etc

**URL:** <https://discourse.julialang.org/t/computation-with-huge-numbers-bigint-bigfloat-etc/37591>\
**Category:** General Usage\
**Created:** [April 14, 2020, 9:48pm UTC](https://discourse.julialang.org/t/computation-with-huge-numbers-bigint-bigfloat-etc/37591 "2020-04-14T21:48:17Z")\
**Posts on this page:** 3\
**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:** [April 14, 2020, 9:48pm UTC](https://discourse.julialang.org/t/computation-with-huge-numbers-bigint-bigfloat-etc/37591/1 "2020-04-14T21:48:17Z")

</div>

I am trying to compute the number `binomial(100,50)/2^100`, among others.

The following code gives an explicit rational value of type `Rational{BigInt}` for that number.

```
julia> using Combinatorics 
julia> binomial(big(100),50) // big(2)^100
12611418068195524166851562157//158456325028528675187087900672

```

Unfortunately, trying to convert this value to `Float64` using the `float` function gives an error.

```
julia> julia> float(binomial(big(100),50) // big(2)^100)
Error showing value of type BigFloat:
ERROR: AssertionError: length(int) == 1
[...]

```

Why? I would expect `float` to be able to handle such an argument.

```
julia> float(Rational{BigInt})
BigFloat

julia> BigFloat(binomial(big(100),50) // big(2)^100)
Error showing value of type BigFloat:
ERROR: AssertionError: length(int) == 1

```

I finally succeeded to obtain an approximate value with

```
julia> convert(Float64, binomial(big(100),50) // big(2)^100)
0.07958923738717877

```

Still I am puzzled by the errors I obtained. How can I obtain a value of type `BigFloat` for my number? This seems to be the correct type for these kind of computations.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 14, 2020, 10:13pm UTC](https://discourse.julialang.org/t/computation-with-huge-numbers-bigint-bigfloat-etc/37591/2 "2020-04-14T22:13:45Z")

</div>

> [@harven](#):
>
> Unfortunately, trying to convert this value to `Float64` using the `float` function gives an error.
> 
> ```julia
> julia> float(binomial(big(100),50) // big(2)^100)
> Error showing value of type BigFloat:
> ERROR: AssertionError: length(int) == 1
> [...]
> 
> ```

I can’t reproduce your problem:

```julia
julia> float(binomial(big(100),50) // big(2)^100)
7.95892373871787614981270502421704614029315404247333213573478705171737601631321e-02

```

Can you try it in a fresh Julia session?

---

<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:** [April 15, 2020, 1:16am UTC](https://discourse.julialang.org/t/computation-with-huge-numbers-bigint-bigfloat-etc/37591/3 "2020-04-15T01:16:45Z")

</div>

Indeed, something went wrong with my session. Thanks.
