Package Exports
- @stdlib/math-base-special-hypotf
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stdlib/math-base-special-hypotf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
hypotf
Compute the hypotenuse avoiding overflow and underflow (single-precision).
Installation
npm install @stdlib/math-base-special-hypotf
Usage
var hypotf = require( '@stdlib/math-base-special-hypotf' );
hypotf( x, y )
Computes the hypotenuse avoiding overflow and underflow (single-precision).
var h = hypotf( -5.0, 12.0 );
// returns 13.0
h = hypotf( -0.0, -0.0 );
// returns +0.0
If either argument is NaN
, the function returns NaN
.
var h = hypotf( NaN, 12.0 );
// returns NaN
h = hypotf( 5.0, NaN );
// returns NaN
Examples
var randu = require( '@stdlib/random-base-randu' );
var round = require( '@stdlib/math-base-special-round' );
var hypotf = require( '@stdlib/math-base-special-hypotf' );
var x;
var y;
var h;
var i;
for ( i = 0; i < 100; i++ ) {
x = round( randu()*100.0 ) - 50.0;
y = round( randu()*100.0 ) - 50.0;
h = hypotf( x, y );
console.log( 'h(%d,%d) = %d', x, y, h );
}
C APIs
Installation
npm install @stdlib/math-base-special-hypotf
Usage
#include "stdlib/math/base/special/hypotf.h
stdlib_base_hypotf( x, y )
Computes the hypotenuse avoiding overflow and underflow (single-precision).
float h = stdlib_base_hypotf( 5.0f, 12.0f );
// returns 13.0f
The function accepts the following arguments:
- x:
[in] float
input value. - y:
[in] float
input value.
float stdlib_base_hypotf( const float x, const float y );
Examples
#include "stdlib/math/base/special/hypotf.h"
#include <stdio.h>
int main() {
float x[] = { 3.0f, 4.0f, 5.0f, 12.0f };
float y;
int i;
for ( i = 0; i < 4; i += 2 ) {
y = stdlib_base_hypotf( x[ i ], x[ i+1 ] );
printf( "hypot(%f, %f) = %f\n", x[ i ], x[ i+1 ], y );
}
}
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2021. The Stdlib Authors.