
Security News
AI Has Taken Over Open Source
Vibe coding at scale is reshaping how packages are created, contributed, and selected across the software supply chain
@stdlib/math-base-special-absf
Advanced tools
Compute the absolute value of a single-precision floating-point number.
Compute the absolute value of a single-precision floating-point number.
The absolute value is defined as
npm install @stdlib/math-base-special-absf
var absf = require( '@stdlib/math-base-special-absf' );
Computes the absolute value of a single-precision floating-point number.
var v = absf( -1.0 );
// returns 1.0
v = absf( 2.0 );
// returns 2.0
v = absf( 0.0 );
// returns 0.0
v = absf( -0.0 );
// returns 0.0
v = absf( NaN );
// returns NaN
var randu = require( '@stdlib/random-base-randu' );
var round = require( '@stdlib/math-base-special-round' );
var absf = require( '@stdlib/math-base-special-absf' );
var rand;
var i;
for ( i = 0; i < 100; i++ ) {
rand = round( randu() * 100.0 ) - 50.0;
console.log( 'absf(%d) = %d', rand, absf( rand ) );
}
#include "stdlib/math/base/special/absf.h"
Computes the squared absolute value of a single-precision floating-point number.
float y = stdlib_base_absf( -5.0f );
// returns 5.0f
The function accepts the following arguments:
[in] float input value.float stdlib_base_absf( const float x );
#include "stdlib/math/base/special/absf.h"
#include <stdio.h>
int main() {
float x[] = { 3.14f, -3.14f, 0.0f, 0.0f/0.0f };
float y;
int i;
for ( i = 0; i < 4; i++ ) {
y = stdlib_base_absf( x[ i ] );
printf( "|%f| = %f\n", x[ i ], y );
}
}
@stdlib/math/base/special/abs: compute the absolute value of a double-precision floating-point number.@stdlib/math/base/special/abs2f: compute the squared absolute value of a single-precision floating-point number.@stdlib/math/base/special/labs: compute an absolute value of a signed 32-bit integer.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.
See LICENSE.
Copyright © 2016-2022. The Stdlib Authors.
FAQs
Compute the absolute value of a single-precision floating-point number.
The npm package @stdlib/math-base-special-absf receives a total of 61,699 weekly downloads. As such, @stdlib/math-base-special-absf popularity was classified as popular.
We found that @stdlib/math-base-special-absf demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Vibe coding at scale is reshaping how packages are created, contributed, and selected across the software supply chain

Security News
npm invalidated all granular access tokens that bypass 2FA after a fresh Mini Shai-Hulud wave compromised 323 npm packages. Staged publishing also entered public preview.

Research
/Security News
Compromised npm package art-template delivered a Coruna-like iOS Safari exploit framework through a watering-hole attack.