# Power minus one character

**URL:** https://discourse.julialang.org/t/power-minus-one-character/101535
**Category:** General Usage
**Tags:** question, unicode
**Created:** [July 12, 2023, 2:17pm UTC](https://discourse.julialang.org/t/power-minus-one-character/101535 "2023-07-12T14:17:50Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [July 12, 2023, 2:17pm UTC](https://discourse.julialang.org/t/power-minus-one-character/101535/1 "2023-07-12T14:17:50Z")

</div>

Is their a way to print W^{-1} in the console using println(“W…”)?

Is their a unicode character for it?

---

<div class="post-metadata">

### Author: ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)
#### Post date: [July 12, 2023, 2:23pm UTC](https://discourse.julialang.org/t/power-minus-one-character/101535/2 "2023-07-12T14:23:38Z")

</div>

In [Superscripts and Subscripts (Unicode block) - Wikipedia](https://en.wikipedia.org/wiki/Superscripts_and_Subscripts_(Unicode_block)) and [Unicode subscripts and superscripts - Wikipedia](https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts) they mention a superscript minus and a superscript 1, so you could do W⁻¹, here it looks a bit nicer in code `W⁻¹`.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [July 12, 2023, 2:32pm UTC](https://discourse.julialang.org/t/power-minus-one-character/101535/3 "2023-07-12T14:32:17Z")

</div>

Thanks a lot! I copy and pasted what you wrote, and it works. 🙂

Is there a way to type this in the REPL without using copy and paste?

---

<div class="post-metadata">

### Author: ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)
#### Post date: [July 12, 2023, 2:38pm UTC](https://discourse.julialang.org/t/power-minus-one-character/101535/4 "2023-07-12T14:38:03Z")

</div>

`W\highminus<TAB>\^1<TAB>` see [Unicode Input · The Julia Language](https://docs.julialang.org/en/v1/manual/unicode-input/)

---

<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: [July 12, 2023, 2:44pm UTC](https://discourse.julialang.org/t/power-minus-one-character/101535/5 "2023-07-12T14:44:15Z")

</div>

> [@kellertuer](#):
>
> `W\highminus<TAB>\^1<TAB>`

Easier: `W\^-1<tab>`. If you copy-and-paste a symbol into the REPL help, it will tell you how to type it:

```julia-auto
help?> W⁻¹
"W⁻¹" can be typed by W\^-1<tab>

```

---

<div class="post-metadata">

### Author: ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)
#### Post date: [July 12, 2023, 2:50pm UTC](https://discourse.julialang.org/t/power-minus-one-character/101535/6 "2023-07-12T14:50:41Z")

</div>

If you need the output to be dynamic, you can use these functions I wrote a while ago.

```julia
julia> s = "W" * superscriptnumber(-1)
"W⁻¹"

julia> s = "W" * superscriptnumber(-3000)
"W⁻³⁰⁰⁰"

julia> ["W" * subscriptnumber(i) for i in 0:4]
5-element Vector{String}:
 "W₀"
 "W₁"
 "W₂"
 "W₃"
 "W₄"

```

```julia
"""
    subscriptnumber(i::Int) -> s::String

Returns the appropraite unicode string `s` for any numerical subscript `i`.
"""
function subscriptnumber(i::Int)
    if i < 0
        c = [Char(0x208B)]
    else
        c = []
    end
    for d in reverse(digits(abs(i)))
        push!(c, Char(0x2080+d))
    end
    return join(c)
end
export subscriptnumber

"""
    superscriptnumber(i::Int) -> s::String

Returns the appropraite unicode string `s` for any numerical superscript `i`.
"""
function superscriptnumber(i::Int)
    if i < 0
        c = [Char(0x207B)]
    else
        c = []
    end
    for d in reverse(digits(abs(i)))
        if d == 0 push!(c, Char(0x2070)) end
        if d == 1 push!(c, Char(0x00B9)) end
        if d == 2 push!(c, Char(0x00B2)) end
        if d == 3 push!(c, Char(0x00B3)) end
        if d > 3 push!(c, Char(0x2070+d)) end
    end
    return join(c)
end
export superscriptnumber

```
