@@ -3,7 +3,7 @@ use pyo3::{Python, prelude::*};
33
44/// Edge values for testing floating-point functions.
55/// Includes: zeros, infinities, various NaNs, subnormals, and values at different scales.
6- pub ( crate ) const EDGE_VALUES : [ f64 ; 30 ] = [
6+ pub ( crate ) const EDGE_VALUES : [ f64 ; 49 ] = [
77 // Zeros
88 0.0 ,
99 -0.0 ,
@@ -15,9 +15,13 @@ pub(crate) const EDGE_VALUES: [f64; 30] = [
1515 -f64:: NAN ,
1616 // Additional NaN with different payload (quiet NaN with payload 1)
1717 f64:: from_bits ( 0x7FF8_0000_0000_0001_u64 ) ,
18+ // Signaling NaN (sNaN) - may trigger FP exceptions on some platforms
19+ f64:: from_bits ( 0x7FF0_0000_0000_0001_u64 ) ,
1820 // Subnormal (denormalized) values
1921 f64:: MIN_POSITIVE * 0.5 , // smallest subnormal
2022 -f64:: MIN_POSITIVE * 0.5 ,
23+ 5e-324 , // smallest positive subnormal
24+ -5e-324 ,
2125 // Boundary values
2226 f64:: MIN_POSITIVE , // smallest positive normal
2327 f64:: MAX , // largest finite
@@ -27,23 +31,43 @@ pub(crate) const EDGE_VALUES: [f64; 30] = [
2731 -f64:: MAX * 0.5 ,
2832 1e308 ,
2933 -1e308 ,
34+ // Values near overflow threshold for common operations
35+ 1e154 , // sqrt of this is ~1e77, exp of this overflows
36+ -1e154 ,
37+ 710.0 , // exp(710) ≈ overflow threshold
38+ -745.0 , // exp(-745) ≈ underflow threshold
3039 // Small scale
3140 1e-10 ,
3241 -1e-10 ,
3342 1e-300 ,
43+ -1e-300 ,
3444 // Normal scale
3545 1.0 ,
3646 -1.0 ,
3747 0.5 ,
3848 -0.5 ,
3949 2.0 ,
40- // Trigonometric special values (where sin/cos/tan have exact or near-zero results)
41- std:: f64:: consts:: PI , // sin(PI) ≈ 0
50+ -2.0 ,
51+ // Values near 1.0 (important for log, expm1, log1p)
52+ 1.0 - 1e-15 , // just below 1
53+ 1.0 + 1e-15 , // just above 1
54+ f64:: EPSILON ,
55+ 1.0 - f64:: EPSILON ,
56+ 1.0 + f64:: EPSILON ,
57+ // Mathematical constants
58+ std:: f64:: consts:: E ,
59+ std:: f64:: consts:: LN_2 ,
60+ std:: f64:: consts:: LOG10_E ,
61+ // Trigonometric special values
62+ std:: f64:: consts:: PI ,
4263 -std:: f64:: consts:: PI ,
43- std:: f64:: consts:: FRAC_PI_2 , // cos(PI/2) ≈ 0
64+ std:: f64:: consts:: FRAC_PI_2 ,
4465 -std:: f64:: consts:: FRAC_PI_2 ,
45- std:: f64:: consts:: FRAC_PI_4 , // tan(PI/4) = 1
46- std:: f64:: consts:: TAU , // sin(2*PI) ≈ 0, cos(2*PI) = 1
66+ std:: f64:: consts:: FRAC_PI_4 ,
67+ std:: f64:: consts:: TAU ,
68+ // Near-integer values (important for ceil, floor, trunc, round)
69+ 0.49999999999999994 , // rounds to 0
70+ 0.50000000000000006 , // rounds to 1
4771] ;
4872
4973pub ( crate ) fn unwrap < ' py > (
0 commit comments