mathjs/docs/reference/functions/hasNumericValue.md
2022-03-01 13:04:09 +01:00

60 lines
1.9 KiB
Markdown

---
layout: default
---
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
<h1 id="function-hasnumericvalue">Function hasNumericValue <a href="#function-hasnumericvalue" title="Permalink">#</a></h1>
Test whether a value is an numeric value.
In case of a string, true is returned if the string contains a numeric value.
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
```js
math.hasNumericValue(x)
```
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
Parameter | Type | Description
--------- | ---- | -----------
`x` | * | Value to be tested
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
Type | Description
---- | -----------
boolean | Returns true when `x` is a `number`, `BigNumber`, `Fraction`, `Boolean`, or a `String` containing number. Returns false for other types. Throws an error in case of unknown types.
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
Type | Description
---- | -----------
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
```js
math.hasNumericValue(2) // returns true
math.hasNumericValue('2') // returns true
math.isNumeric('2') // returns false
math.hasNumericValue(0) // returns true
math.hasNumericValue(math.bignumber(500)) // returns true
math.hasNumericValue(math.fraction(4)) // returns true
math.hasNumericValue(math.complex('2-4i') // returns false
math.hasNumericValue([2.3, 'foo', false]) // returns [true, false, true]
```
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
[isZero](isZero.html),
[isPositive](isPositive.html),
[isNegative](isNegative.html),
[isInteger](isInteger.html),
[isNumeric](isNumeric.html)