time-to-botec/js/node_modules/@stdlib/math/base/special/max/README.md
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

3.0 KiB

max

Return the maximum value.

Usage

var max = require( '@stdlib/math/base/special/max' );

max( [x[, y[, ...args]]] )

Returns the maximum value.

var v = max( 4.2, 3.14 );
// returns 4.2

v = max( +0.0, -0.0 );
// returns +0.0

v = max( 4.2, 3.14, -1.0, 6.8 );
// returns 6.8

If any argument is NaN, the function returns NaN.

var v = max( 4.2, NaN );
// returns NaN

v = max( NaN, 3.14 );
// returns NaN

If not provided any arguments, the function returns -infinity.

var v = max();
// returns -Infinity

Notes

  • When an empty set is considered a subset of the extended reals (all real numbers, including positive and negative infinity), negative infinity is the least upper bound. Similar to zero being the identity element for the sum of an empty set and to one being the identity element for the product of an empty set, negative infinity is the identity element for the maximum, and thus, max() = -infinity.

Examples

var minstd = require( '@stdlib/random/base/minstd-shuffle' );
var max = require( '@stdlib/math/base/special/max' );

var x;
var y;
var v;
var i;

for ( i = 0; i < 100; i++ ) {
    x = minstd();
    y = minstd();
    v = max( x, y );
    console.log( 'max(%d,%d) = %d', x, y, v );
}