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

Defines

#define LDBL_TRUE_MIN   __LDBL_DENORM_MIN__

Functions

double npy_copysign (double x, double y)
int _npy_signbit_f (float x)
int _npy_signbit_ld (long double x)
static double _next (double x, int p)
static float _nextf (float x, int p)
static 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)
int npy_get_floatstatus (void)
int npy_clear_floatstatus (void)
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

Define Documentation

#define LDBL_TRUE_MIN   __LDBL_DENORM_MIN__
The below code is provided for compilers which do not yet provide C11 compatibility (gcc 4.5 and older)

Function Documentation

static double _next ( double  x,
int  p 
) [static]
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.

static float _nextf ( float  x,
int  p 
) [static]

<

|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
static npy_longdouble _nextl ( npy_longdouble  x,
int  p 
) [static]

<

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().

int npy_clear_floatstatus ( void  )

Referenced by HALF_remainder(), and PyUFunc_getfperr().

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.

int npy_get_floatstatus ( void  )
end repeat*
Decorate all the math functions which are available on the current platform
Functions to set the floating point status word. keep in sync with NO_FLOATING_POINT_SUPPORT in ufuncobject.h
Solaris --------------------------------------------------------
<blockquote> --------ignoring SunOS ieee_flags approach, someone else can</blockquote>

System Message: WARNING/2 (<string>, line 2) Block quote ends without a blank line; unexpected unindent.
  • deal with that!
MS Windows -----------------------------------------------------
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
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

<

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_invalid ( void  )

Referenced by npy_half_spacing().

Referenced by npy_half_spacing().

type npy_spacing suff ( @type @  x)
begin repeat
suff = f,,l# #SUFF = F,,L# #type = npy_float, npy_double, npy_longdouble#
XXX: npy isnan/isinf may be optimized by bit twiddling

Referenced by suff().


Variable Documentation

volatile double _npy_floatstatus_big = 1e300 [static]
volatile double _npy_floatstatus_inf [static]
volatile double _npy_floatstatus_small = 1e-300 [static]
volatile double _npy_floatstatus_x [static]
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 [static]