numpy 2.0.0
src/npymath/ieee754.c.src File Reference
#include "npy_math_common.h"
#include "npy_math_private.h"
#include "_signbit.c"

Functions

double npy_copysign (double x, double y)
int _npy_signbit_f (float x)
int _npy_signbit_ld (long double x)
double _next (double x, int p)
float _nextf (float x, int p)
npy_longdouble _nextl (npy_longdouble x, int p)
double npy_nextafter (double x, double y)
float npy_nextafterf (float x, float y)
npy_longdouble npy_nextafterl (npy_longdouble x, npy_longdouble y)
type npy_spacing suff (@type @x)
void npy_set_floatstatus_divbyzero (void)
void npy_set_floatstatus_overflow (void)
void npy_set_floatstatus_underflow (void)
void npy_set_floatstatus_invalid (void)

Variables

static volatile double _npy_floatstatus_x
static volatile double _npy_floatstatus_zero = 0.0
static volatile double _npy_floatstatus_big = 1e300
static volatile double _npy_floatstatus_small = 1e-300
static volatile double _npy_floatstatus_inf

Function Documentation

double _next ( double  x,
int  p 
)
FIXME: There is a lot of redundancy between _next* and npy_nextafter*. refactor this at some point
p >= 0, returnx x + nulp p < 0, returnx x - nulp

<

|x|

Docutils System Messages

System Message: ERROR/3 (<string>, line 1); backlink Undefined substitution referenced: "x".

<

x is nan

<

x == 0

<

return +minsubnormal

<

return -minsubnormal

<

raise underflow flag

<

x -= ulp

<

x += ulp

<

overflow

<

underflow

<

raise underflow flag

References EXTRACT_WORDS, and INSERT_WORDS.

float _nextf ( float  x,
int  p 
)

<

|x|

Docutils System Messages

System Message: ERROR/3 (<string>, line 1); backlink Undefined substitution referenced: "x".

<

x is nan

<

x == 0

<

return +minsubnormal

<

return -minsubnormal

<

raise underflow flag

<

x -= ulp

<

x += ulp

<

overflow

<

underflow

<

raise underflow flag

npy_longdouble _nextl ( npy_longdouble  x,
int  p 
)

<

x is nan

<

return +-minsubnormal

<

raise underflow flag

<

x -= ulp

<

x += ulp

<

overflow

<

underflow

<

raise underflow flag

References SET_FLOAT_WORD.

int _npy_signbit_f ( float  x)

References _npy_signbit_d().

int _npy_signbit_ld ( long double  x)

References _npy_signbit_d().

double npy_copysign ( double  x,
double  y 
)
vim:syntax=c
Low-level routines related to IEEE-754 format

References GET_HIGH_WORD, and SET_HIGH_WORD.

Referenced by c().

double npy_nextafter ( double  x,
double  y 
)
nextafter code taken from BSD math lib, the code contains the following notice:

System Message: SEVERE/4 (<string>, line 4)
Missing matching underline for section title overline.

====================================================
Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 
Developed at SunPro, a Sun Microsystems, Inc. business. Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved. ====================================================

<

|x|

Docutils System Messages

System Message: ERROR/3 (<string>, line 1); backlink Undefined substitution referenced: "x".

<

|y|

Docutils System Messages

System Message: ERROR/3 (<string>, line 1); backlink Undefined substitution referenced: "y".

<

x is nan

<

y is nan

<

x=y, return y

<

x == 0

<

return +-minsubnormal

<

raise underflow flag

<

x > 0

<

x > y, x -= ulp

<

x < y, x += ulp

<

x < 0

<

x < y, x -= ulp

<

x > y, x += ulp

<

overflow

<

underflow

<

raise underflow flag

Referenced by TIMEDELTA_md_m_multiply().

float npy_nextafterf ( float  x,
float  y 
)

<

|x|

Docutils System Messages

System Message: ERROR/3 (<string>, line 1); backlink Undefined substitution referenced: "x".

<

|y|

Docutils System Messages

System Message: ERROR/3 (<string>, line 1); backlink Undefined substitution referenced: "y".

<

x is nan

<

y is nan

<

x=y, return y

<

x == 0

<

return +-minsubnormal

<

raise underflow flag

<

x > 0

<

x > y, x -= ulp

<

x < y, x += ulp

<

x < 0

<

x < y, x -= ulp

<

x > y, x += ulp

<

overflow

<

underflow

<

raise underflow flag

References _npy_floatstatus_zero.

npy_longdouble npy_nextafterl ( npy_longdouble  x,
npy_longdouble  y 
)

<

x or y is nan

<

x=y, return y

<

return +-minsubnormal

<

raise underflow flag

<

x -= ulp

<

x += ulp

<

overflow

<

underflow

<

raise underflow flag

void npy_set_floatstatus_divbyzero ( void  )
Functions that set the floating point error status word.

Referenced by _logical_not().

void npy_set_floatstatus_invalid ( void  )

Referenced by npy_half_spacing().

void npy_set_floatstatus_overflow ( void  )

Referenced by npy_half_spacing().

void npy_set_floatstatus_underflow ( void  )
type npy_spacing suff ( @type @  x)
begin repeat
suff = f,,l# #SUFF = F,,L# type = float, double, npy_longdouble#

XXX: npy isnan/isinf may be optimized by bit twiddling

Referenced by OBJECT_fill(), and suff().


Variable Documentation

volatile double _npy_floatstatus_big = 1e300
volatile double _npy_floatstatus_inf
volatile double _npy_floatstatus_small = 1e-300
volatile double _npy_floatstatus_x [static]
end repeat*
Decorate all the math functions which are available on the current platform
Functions to set the floating point status word.
By using a volatile floating point value, the compiler is forced to actually do the requested operations because of potential concurrency.
We shouldn't write multiple values to a single global here, because that would cause a race condition.
volatile double _npy_floatstatus_zero = 0.0

Referenced by npy_nextafterf().