Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Nov 17, 2024
1 parent 704c1ce commit 117c472
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<section class="release" id="unreleased">

## Unreleased (2024-11-15)
## Unreleased (2024-11-17)

<section class="packages">

Expand Down Expand Up @@ -284,6 +284,7 @@ A total of 5 people contributed to this release. Thank you to the following cont

<details>

- [`8a03f83`](https://github.com/stdlib-js/stdlib/commit/8a03f833d9808c17418225664d7250b94fb0e1b5) - **refactor:** use constant package in `math/base/special/fmodf` (#3120) [(#3120)](https://github.com/stdlib-js/stdlib/pull/3120) _(by Gunj Joshi)_
- [`15dff30`](https://github.com/stdlib-js/stdlib/commit/15dff30135c09d5afa4b81c0ef662c68b65b6013) - **refactor:** use macros in addon and update examples in `math/base/assert/is-evenf` [(#3115)](https://github.com/stdlib-js/stdlib/pull/3115) _(by Gunj Joshi, Athan Reines)_
- [`e5bfdff`](https://github.com/stdlib-js/stdlib/commit/e5bfdff2d2c137f84eb5f925f8d63a3729d05eb2) - **docs:** update functions descriptions in `math/base/special/cceil` [(#3114)](https://github.com/stdlib-js/stdlib/pull/3114) _(by Gunj Joshi)_
- [`79dc5cf`](https://github.com/stdlib-js/stdlib/commit/79dc5cf4044f4f90a7005389e4740f14a820a967) - **bench:** generate numbers outside loops in `math/base/special/cfloorf` [(#3113)](https://github.com/stdlib-js/stdlib/pull/3113) _(by Gunj Joshi)_
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Mohammad Kaif <98884589+Kaif987@users.noreply.github.com>
Momtchil Momtchev <momtchil@momtchev.com>
Muhammad Haris <harriskhan047@outlook.com>
Naresh Jagadeesan <naresh.naresh000@gmail.com>
Neeraj Pathak <neerajrpathak710@gmail.com>
NightKnight <Ahmedatwa866@yahoo.com>
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
Nourhan Hasan <109472010+TheNourhan@users.noreply.github.com>
Expand Down
9 changes: 6 additions & 3 deletions base/special/fmodf/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"@stdlib/constants/float32/exponent-bias",
"@stdlib/constants/float32/exponent-mask",
"@stdlib/constants/float32/abs-mask",
"@stdlib/constants/float32/min-base2-exponent"
"@stdlib/constants/float32/min-base2-exponent",
"@stdlib/constants/float32/precision"
]
},
{
Expand All @@ -63,7 +64,8 @@
"@stdlib/constants/float32/exponent-bias",
"@stdlib/constants/float32/exponent-mask",
"@stdlib/constants/float32/abs-mask",
"@stdlib/constants/float32/min-base2-exponent"
"@stdlib/constants/float32/min-base2-exponent",
"@stdlib/constants/float32/precision"
]
},
{
Expand All @@ -83,7 +85,8 @@
"@stdlib/constants/float32/exponent-bias",
"@stdlib/constants/float32/exponent-mask",
"@stdlib/constants/float32/abs-mask",
"@stdlib/constants/float32/min-base2-exponent"
"@stdlib/constants/float32/min-base2-exponent",
"@stdlib/constants/float32/precision"
]
}
]
Expand Down
12 changes: 8 additions & 4 deletions base/special/fmodf/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
#include "stdlib/constants/float32/exponent_mask.h"
#include "stdlib/constants/float32/exponent_bias.h"
#include "stdlib/constants/float32/min_base2_exponent.h"
#include "stdlib/constants/float32/precision.h"
#include <stdint.h>

static const float ZERO[] = { 0.0f, -0.0f };

/**
* Evaluates the modulus function for single-precision floating-point numbers.
*
Expand All @@ -52,7 +55,6 @@
* // returns 2.9f
*/
float stdlib_base_fmodf( const float x, const float y ) {
const float ZERO[] = { 0.0f, -0.0f };
uint32_t uhx;
uint32_t uhy;
int32_t hx;
Expand Down Expand Up @@ -101,7 +103,7 @@ float stdlib_base_fmodf( const float x, const float y ) {
ix -= 1;
}
} else {
ix = ( hx >> 23 ) - STDLIB_CONSTANT_FLOAT32_EXPONENT_BIAS;
ix = ( hx >> ( STDLIB_CONSTANT_FLOAT32_PRECISION - 1 ) ) - STDLIB_CONSTANT_FLOAT32_EXPONENT_BIAS;
}

// determine iy = ilogb(y)
Expand All @@ -111,7 +113,9 @@ float stdlib_base_fmodf( const float x, const float y ) {
for ( i = ( hy << 8 ); i >= 0; i <<= 1 ) {
iy -= 1;
}
} else iy = ( hy >> 23 ) - STDLIB_CONSTANT_FLOAT32_EXPONENT_BIAS;
} else {
iy = ( hy >> ( STDLIB_CONSTANT_FLOAT32_PRECISION - 1 ) ) - STDLIB_CONSTANT_FLOAT32_EXPONENT_BIAS;
}

// set up {hx,lx}, {hy,ly} and align y to x
if ( ix >= STDLIB_CONSTANT_FLOAT32_MIN_BASE2_EXPONENT ) {
Expand Down Expand Up @@ -160,7 +164,7 @@ float stdlib_base_fmodf( const float x, const float y ) {
}
if ( iy >= STDLIB_CONSTANT_FLOAT32_MIN_BASE2_EXPONENT ) {
// normalize output
hx = ( ( hx - 0x00800000 ) | ( ( iy + STDLIB_CONSTANT_FLOAT32_EXPONENT_BIAS ) << 23 ) );
hx = ( ( hx - 0x00800000 ) | ( ( iy + STDLIB_CONSTANT_FLOAT32_EXPONENT_BIAS ) << ( STDLIB_CONSTANT_FLOAT32_PRECISION - 1 ) ) );
stdlib_base_float32_from_word( (uint32_t)( hx | sx ), &xc );
} else {
// subnormal output
Expand Down
12 changes: 6 additions & 6 deletions base/special/fmodf/test/fixtures/julia/runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ julia> gen( x, y, \"data.json\" );
"""
function gen( x, y, name )
z = Array{Float32}( undef, length( x ) );
for i in eachindex(x)
z[ i ] = Float32(rem( Float32(x[ i ]), Float32(y[ i ])) )
for i in eachindex( x )
z[ i ] = Float32( rem( Float32( x[ i ] ), Float32( y[ i ] ) ) );
end

# Store data to be written to file as a collection:
Expand All @@ -67,13 +67,13 @@ file = @__FILE__;
dir = dirname( file );

# Subnormal results:
x = range(1.18e-38, stop = 1.0e-45, length = 2001)
y = range(1.18e-38, stop = 1.0e-45, length = 2001)
x = range( 1.18e-38, stop = 1.0e-45, length = 2001 );
y = range( 1.18e-38, stop = 1.0e-45, length = 2001 );
gen( x, y, "subnormal_results.json" );

# x small, y small:
x = rand( 5001 ) .* 100
y = rand( 5001 ) .* 100
x = rand( 5001 ) .* 100;
y = rand( 5001 ) .* 100;
gen( x, y, "small_small.json" );

# x small, y large:
Expand Down

0 comments on commit 117c472

Please sign in to comment.