# Why get 0 for 2^(3^4)?

**URL:** <https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 2, 2022, 8:39am UTC](https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114 "2022-10-02T08:39:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pppoe5](https://avatars.discourse-cdn.com/v4/letter/p/ee7513/32.png) [@pppoe5](https://discourse.julialang.org/u/pppoe5)\
**Post date:** [October 2, 2022, 8:39am UTC](https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114/1 "2022-10-02T08:39:02Z")

</div>

In Julia `REPL`, I input `2^(3^4)` or `big(2^(3^4))`, still give me `0`.  
So, how to get the right answer?

---

<div class="post-metadata">

**Author:** ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Post date:** [October 2, 2022, 8:43am UTC](https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114/2 "2022-10-02T08:43:39Z")

</div>

Julia is not overflow-aware for native numerical types. The answer is `2^81` which can’t be represented by the Int64 type, you only get the last 64 bits which are all zero. You must either use Float (i.e. `2.0^(3^4)`) or a larger integer type like `big"2"^(3^4)` (this can accomodate arbitrarily large integers), or `int128"2"^(3^4)`.

---

<div class="post-metadata">

**Author:** ![pppoe5](https://avatars.discourse-cdn.com/v4/letter/p/ee7513/32.png) [@pppoe5](https://discourse.julialang.org/u/pppoe5)\
**Post date:** [October 2, 2022, 9:12am UTC](https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114/3 "2022-10-02T09:12:05Z")

</div>

cool! But what’s the means for `"2"`

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [October 2, 2022, 9:20am UTC](https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114/4 "2022-10-02T09:20:24Z")

</div>

[`big"2"`](https://docs.julialang.org/en/v1/base/numbers/#Core.@big_str) (and not `"2"` alone) is the [string literal](https://docs.julialang.org/en/v1/manual/metaprogramming/#meta-non-standard-string-literals) to construct an [arbitrary precision number](https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/#Arbitrary-Precision-Arithmetic)

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [October 2, 2022, 7:35pm UTC](https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114/5 "2022-10-02T19:35:14Z")

</div>

And note the difference between `big(2^(3^4))` on one side and `big(2)^(3^4))` on the other.  
In the first case the computtion is made using `Int64` numbers, and only the result is converted to `BigInt`, when “it is too late” and the number has already overflown.  
In the second case instead the operation involves at least one `BigInt` and all operands are casted to `BigInt` leading to the right result.

---

<div class="post-metadata">

**Author:** ![pppoe5](https://avatars.discourse-cdn.com/v4/letter/p/ee7513/32.png) [@pppoe5](https://discourse.julialang.org/u/pppoe5)\
**Post date:** [October 3, 2022, 3:03am UTC](https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114/6 "2022-10-03T03:03:39Z")

</div>

Again, so let’s do this work

```julia
x=2
y=81

# big"x"^y
# big"$(x)"^y
big(x)^y

```

So, I stiil confused with `big"x"`.

---

<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:** [October 3, 2022, 3:07am UTC](https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114/7 "2022-10-03T03:07:20Z")

</div>

macros are expanded at parse time which is before x has a value. a string macro can only see the literal contents of the string.

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [October 3, 2022, 3:54am UTC](https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114/8 "2022-10-03T03:54:49Z")

</div>

```julia
julia> x = 2; y = big"2";

julia> typeof(x)
Int64

julia> typeof(y)
BigInt

```
