# What is rand(big(1:6))?

**URL:** <https://discourse.julialang.org/t/what-is-rand-big-1-6/22865>\
**Category:** General Usage\
**Created:** [April 7, 2019, 8:39am UTC](https://discourse.julialang.org/t/what-is-rand-big-1-6/22865 "2019-04-07T08:39:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [April 7, 2019, 8:39am UTC](https://discourse.julialang.org/t/what-is-rand-big-1-6/22865/1 "2019-04-07T08:39:19Z")

</div>

I’m reading the Julia documentation following this link: [https://fredrikekre.github.io/stdlib/Random.html](https://fredrikekre.github.io/stdlib/Random.html)  
and I encounter this one line of code:  
`rand(big(1:6))`  
Somehow I can not find out this `big(1:6)`? Could anyone tell me what is this?

---

<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:** [April 7, 2019, 8:43am UTC](https://discourse.julialang.org/t/what-is-rand-big-1-6/22865/2 "2019-04-07T08:43:34Z")

</div>

It’s not valid anymore, it used to mean what we write now `big.(1:6)`, or `big(1):big(6)`.

---

<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:** [April 7, 2019, 8:52am UTC](https://discourse.julialang.org/t/what-is-rand-big-1-6/22865/3 "2019-04-07T08:52:27Z")

</div>

Note that this is corrected in the [official docs](https://docs.julialang.org/en/v1.1/), maybe you should read that instead?

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [April 7, 2019, 8:52am UTC](https://discourse.julialang.org/t/what-is-rand-big-1-6/22865/4 "2019-04-07T08:52:59Z")

</div>

> julia\> big(1)  
> 1
> 
> julia\> typeof(ans)  
> BigInt
> 
> julia\> big(1.0)  
> 1.0
> 
> julia\> typeof(ans)  
> BigFloat

I checked the big function, it looks like this function will return the big counterpart of the input parameter. I guess the main difference between Int and BigInt is that, BigInt has a big interval?

---

<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:** [April 7, 2019, 8:55am UTC](https://discourse.julialang.org/t/what-is-rand-big-1-6/22865/5 "2019-04-07T08:55:39Z")

</div>

`BigInt` represents arbitrary precision integers, basically limited only by the RAM of the computer.

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [April 7, 2019, 9:01am UTC](https://discourse.julialang.org/t/what-is-rand-big-1-6/22865/6 "2019-04-07T09:01:45Z")

</div>

Very good explanations. Is there a way to print out this `BigInt` representation of, say the number 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:** [April 7, 2019, 9:04am UTC](https://discourse.julialang.org/t/what-is-rand-big-1-6/22865/7 "2019-04-07T09:04:24Z")

</div>

Yes, though its unlikely to be of any help. BigInts are powered by a C library (GMP).

```julia
julia> BigInt(1)
1

julia> dump(BigInt(1))
BigInt
  alloc: Int32 1
  size: Int32 1
  d: Ptr{UInt64} @0x0000000030cac110

```

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [April 7, 2019, 9:09am UTC](https://discourse.julialang.org/t/what-is-rand-big-1-6/22865/8 "2019-04-07T09:09:37Z")

</div>

Thank you. I guess this `@0x0000000030cac110` means the number 1 is stored at this memory location?

---

<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:** [April 7, 2019, 9:10am UTC](https://discourse.julialang.org/t/what-is-rand-big-1-6/22865/9 "2019-04-07T09:10:50Z")

</div>

It means that the GMP library internal structure for this 1 is stored there.  
The `alloc` and `size` fields are also part of the representation.

```julia
julia> a = BigInt(1)
1

julia> b = BigInt(1)
1

julia> dump(a)
BigInt
  alloc: Int32 1
  size: Int32 1
  d: Ptr{UInt64} @0x000000000af3bcb0

julia> dump(b)
BigInt
  alloc: Int32 1
  size: Int32 1
  d: Ptr{UInt64} @0x000000000af3bf60

```

The pointers are different.
