mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
60 lines
1.9 KiB
Markdown
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-isnegative">Function isNegative <a href="#function-isnegative" title="Permalink">#</a></h1>
|
|
|
|
Test whether a value is negative: smaller than zero.
|
|
The function supports types `number`, `BigNumber`, `Fraction`, and `Unit`.
|
|
|
|
The function is evaluated element-wise in case of Array or Matrix input.
|
|
|
|
|
|
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.isNegative(x)
|
|
```
|
|
|
|
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`x` | number | BigNumber | bigint | Fraction | Unit | Array | Matrix | Value to be tested
|
|
|
|
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
boolean | Returns true when `x` is larger than zero. Throws an error in case of an unknown data type.
|
|
|
|
|
|
<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.isNegative(3) // returns false
|
|
math.isNegative(-2) // returns true
|
|
math.isNegative(0) // returns false
|
|
math.isNegative(-0) // returns false
|
|
math.isNegative(math.bignumber(2)) // returns false
|
|
math.isNegative(math.fraction(-2, 5)) // returns true
|
|
math.isNegative('-2') // returns true
|
|
math.isNegative([2, 0, -3]) // returns [false, false, true]
|
|
```
|
|
|
|
|
|
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
|
|
|
[isNumeric](isNumeric.html),
|
|
[isPositive](isPositive.html),
|
|
[isZero](isZero.html),
|
|
[isInteger](isInteger.html)
|