# Checking if variable is a type of number

**URL:** <https://discourse.julialang.org/t/checking-if-variable-is-a-type-of-number/47716>\
**Category:** New to Julia\
**Created:** [October 3, 2020, 11:34pm UTC](https://discourse.julialang.org/t/checking-if-variable-is-a-type-of-number/47716 "2020-10-03T23:34:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![josef](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josef/32/18322_2.png) [@josef](https://discourse.julialang.org/u/josef)\
**Post date:** [October 3, 2020, 11:34pm UTC](https://discourse.julialang.org/t/checking-if-variable-is-a-type-of-number/47716/1 "2020-10-03T23:34:27Z")

</div>

If I want to check if a variable is a number what is a succinct way to do this?

For example I can do something like:

```julia
if typeof(x) == Int64 || typeof(x) == Float64
    #do something
else

```

But the above wouldn’t capture other types of Integers or Floats, e.g. Float32, etc.

Thank you for the help!

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 3, 2020, 11:49pm UTC](https://discourse.julialang.org/t/checking-if-variable-is-a-type-of-number/47716/2 "2020-10-03T23:49:26Z")

</div>

Instead of checking for specific types (`Int64`, `Float64`), check for the supertype:

```julia
if x isa Number
    #do something
else

```
