@stdlib/math-base-special-rempio2f
v0.1.1
Published
Compute `x - nπ/2 = r`.
Readme
rempio2f
Compute
x - nπ/2 = r(single-precision).
Installation
npm install @stdlib/math-base-special-rempio2fUsage
var rempio2f = require( '@stdlib/math-base-special-rempio2f' );rempio2f( x, y )
Computes x - nπ/2 = r.
var y = [ 0.0 ];
var n = rempio2f( 128.0, y );
// returns 81
var y1 = y[ 0 ];
// returns ~0.765When x is NaN or infinite, the function returns 0 and sets y[0] to NaN.
var y = [ 0.0 ];
var n = rempio2f( NaN, y );
// returns 0
var y1 = y[ 0 ];
// returns NaN
y = [ 0.0 ];
n = rempio2f( Infinity, y );
// returns 0
y1 = y[ 0 ];
// returns NaNNotes
- The function returns
nand stores the remainderrasy[0]. - For input values larger than
2^28*π/2in magnitude, the function only returns the last three binary digits ofnand not the full result.
Examples
var linspace = require( '@stdlib/array-base-linspace' );
var rempio2f = require( '@stdlib/math-base-special-rempio2f' );
var x = linspace( 0.0, 100.0, 100 );
var y = [ 0.0 ];
var n;
var i;
for ( i = 0; i < x.length; i++ ) {
n = rempio2f( x[ i ], y );
console.log( '%d - %dπ/2 = %d', x[ i ], n, y[ 0 ] );
}C APIs
Usage
#include "stdlib/math/base/special/rempio2f.h"stdlib_base_rempio2f( x, &rem )
Computes x - nπ/2 = r (single-precision).
#include <stdint.h>
double rem;
int32_t n = stdlib_base_rempio2f( 4.0f, &rem );The function accepts the following arguments:
- x:
[in] floatinput value. - rem:
[out] double*destination for the remainder.
int32_t stdlib_base_rempio2f( const float x, double *rem );Examples
#include "stdlib/math/base/special/rempio2f.h"
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
int main( void ) {
const float x[] = { 0.0f, 1.0f, 4.0f, 128.0f };
double rem;
int32_t n;
int i;
for ( i = 0; i < 4; i++ ) {
n = stdlib_base_rempio2f( x[ i ], &rem );
printf( "%f - %"PRId32"π/2 = %lf\n", x[ i ], n, rem );
}
}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
Copyright
Copyright © 2016-2026. The Stdlib Authors.
