# Valid number

**URL:** <https://discourse.julialang.org/t/valid-number/87727>\
**Category:** General Usage\
**Created:** [September 23, 2022, 9:58pm UTC](https://discourse.julialang.org/t/valid-number/87727 "2022-09-23T21:58:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![qwerty](https://avatars.discourse-cdn.com/v4/letter/q/4491bb/32.png) [@qwerty](https://discourse.julialang.org/u/qwerty)\
**Post date:** [September 23, 2022, 9:58pm UTC](https://discourse.julialang.org/t/valid-number/87727/1 "2022-09-23T21:58:07Z")

</div>

What checks should I do to know if the result of a mathematical operation is a valid number? (I can’t use isfinite with the struct I’m using)  
`isnan()`, `== Inf`, `== -Inf`  
Any other values?

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [September 23, 2022, 10:14pm UTC](https://discourse.julialang.org/t/valid-number/87727/2 "2022-09-23T22:14:49Z")

</div>

`isfinite` is defined as: `isfinite(x::AbstractFloat) = x - x == 0`

---

<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:** [September 24, 2022, 1:07am UTC](https://discourse.julialang.org/t/valid-number/87727/3 "2022-09-24T01:07:00Z")

</div>

> [@qwerty](#):
>
> I can’t use `isfinite` with the struct I’m using

`isfinite` is what you want to check whether something is an “ordinary” floating-point number (as opposed to `±Inf` or `NaN`). (If you can’t use `isfinite`, how do you plan to use `isnan`?)

You could always call `isfinite` on the fields of your `struct`, or define a new `isfinite` method that does this for you.
