# ^2 exhibits postfix behavior

**URL:** <https://discourse.julialang.org/t/2-exhibits-postfix-behavior/66857>\
**Category:** New to Julia\
**Created:** [August 23, 2021, 4:27pm UTC](https://discourse.julialang.org/t/2-exhibits-postfix-behavior/66857 "2021-08-23T16:27:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgpdx](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@dgpdx](https://discourse.julialang.org/u/dgpdx)\
**Post date:** [August 23, 2021, 4:27pm UTC](https://discourse.julialang.org/t/2-exhibits-postfix-behavior/66857/1 "2021-08-23T16:27:16Z")

</div>

julia\> 4 ^2  
16

But

julia\> ^2(4)

ERROR:\*\* syntax: “^” is not a unary operator

What is the rational for this behavior?

---

<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 23, 2021, 4:31pm UTC](https://discourse.julialang.org/t/2-exhibits-postfix-behavior/66857/2 "2021-08-23T16:31:00Z")

</div>

The problem is that it gets parsed as `^(2*4)`.

---

<div class="post-metadata">

**Author:** ![John\_Gibson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_gibson/32/5321_2.png) [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Post date:** [August 23, 2021, 4:32pm UTC](https://discourse.julialang.org/t/2-exhibits-postfix-behavior/66857/3 "2021-08-23T16:32:40Z")

</div>

```julia
julia> ^(2,3)
8

```

---

<div class="post-metadata">

**Author:** ![dgpdx](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@dgpdx](https://discourse.julialang.org/u/dgpdx)\
**Post date:** [August 23, 2021, 4:47pm UTC](https://discourse.julialang.org/t/2-exhibits-postfix-behavior/66857/4 "2021-08-23T16:47:28Z")

</div>

I know that. My question was about ^2(n).

---

<div class="post-metadata">

**Author:** ![dgpdx](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@dgpdx](https://discourse.julialang.org/u/dgpdx)\
**Post date:** [August 23, 2021, 4:48pm UTC](https://discourse.julialang.org/t/2-exhibits-postfix-behavior/66857/5 "2021-08-23T16:48:12Z")

</div>

OK, thanks.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [August 23, 2021, 4:57pm UTC](https://discourse.julialang.org/t/2-exhibits-postfix-behavior/66857/6 "2021-08-23T16:57:52Z")

</div>

Yes, the key is that the function is not `^2`, it’s simply `^`. So it’s not that `^2` is a postfix operator applied to `4`, but rather that `^` is an infix operator _between_ 2 and 4. It’s an infix operator with [very high precedence](https://docs.julialang.org/en/v1/manual/mathematical-operations/#Operator-Precedence-and-Associativity).

Hopefully that gets at the rationale that you’re after here. You could manually create a square operator, but it’s not done automatically:

```julia
julia> square(x) = x^2
square (generic function with 1 method)

julia> square(4)
16

```

---

<div class="post-metadata">

**Author:** ![dgpdx](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@dgpdx](https://discourse.julialang.org/u/dgpdx)\
**Post date:** [August 23, 2021, 5:01pm UTC](https://discourse.julialang.org/t/2-exhibits-postfix-behavior/66857/7 "2021-08-23T17:01:14Z")

</div>

Thanks for the explanation, it’s very helpful!

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 23, 2021, 5:19pm UTC](https://discourse.julialang.org/t/2-exhibits-postfix-behavior/66857/8 "2021-08-23T17:19:13Z")

</div>

would you please mark the correct reply as “solution”?
