Class NDDivision
floor-division and remainder helpers matching NumPy's floor_div_@TYPE@
(loops_arithmetic.dispatch.c.src), integer remainder
(loops_modulo.dispatch.c.src), and the floating-point
npy_floor_divide@c@ / npy_remainder@c@ (Python-divmod port in
npy_math_internal.h.src).
Semantics replicated exactly:
- Integer divide/modulo by zero returns
0(NumPy raises a RuntimeWarning but yields 0, never throwing — C#'s DivideByZeroException must not surface). - Signed integer floor-division rounds toward negative infinity (Python
//), not toward zero like C#/;MIN // -1wraps toMIN(overflow), matching NumPy'snpy_set_floatstatus_overflow(); return NPY_MIN. - Signed integer remainder uses the floored (Python) sign convention: the result has the
sign of the divisor;
MIN % -1 == 0. - Float floor-division/modulo follow CPython's
divmod(fmod, sign-fixup, snap-to-nearest-integer), soa // 0.0is±inf/nan(not forced NaN) and edge cases like0.7 // 0.1 == 6.0and-2.0 // inf == -1.0match.
public static class NDDivision
- Inheritance
-
NDDivision
- Inherited Members
Methods
FloorDivByte(byte, byte)
public static byte FloorDivByte(byte n, byte d)
Parameters
Returns
FloorDivChar(char, char)
public static char FloorDivChar(char n, char d)
Parameters
Returns
FloorDivDouble(double, double)
public static double FloorDivDouble(double a, double b)
Parameters
Returns
FloorDivInt16(short, short)
public static short FloorDivInt16(short n, short d)
Parameters
Returns
FloorDivInt32(int, int)
public static int FloorDivInt32(int n, int d)
Parameters
Returns
FloorDivInt64(long, long)
public static long FloorDivInt64(long n, long d)
Parameters
Returns
FloorDivSByte(sbyte, sbyte)
public static sbyte FloorDivSByte(sbyte n, sbyte d)
Parameters
Returns
FloorDivSingle(float, float)
public static float FloorDivSingle(float a, float b)
Parameters
Returns
FloorDivUInt16(ushort, ushort)
public static ushort FloorDivUInt16(ushort n, ushort d)
Parameters
Returns
FloorDivUInt32(uint, uint)
public static uint FloorDivUInt32(uint n, uint d)
Parameters
Returns
FloorDivUInt64(ulong, ulong)
public static ulong FloorDivUInt64(ulong n, ulong d)
Parameters
Returns
RemByte(byte, byte)
public static byte RemByte(byte n, byte d)
Parameters
Returns
RemChar(char, char)
public static char RemChar(char n, char d)
Parameters
Returns
RemDouble(double, double)
public static double RemDouble(double a, double b)
Parameters
Returns
RemInt16(short, short)
public static short RemInt16(short n, short d)
Parameters
Returns
RemInt32(int, int)
public static int RemInt32(int n, int d)
Parameters
Returns
RemInt64(long, long)
public static long RemInt64(long n, long d)
Parameters
Returns
RemSByte(sbyte, sbyte)
public static sbyte RemSByte(sbyte n, sbyte d)
Parameters
Returns
RemSingle(float, float)
public static float RemSingle(float a, float b)
Parameters
Returns
RemUInt16(ushort, ushort)
public static ushort RemUInt16(ushort n, ushort d)
Parameters
Returns
RemUInt32(uint, uint)
public static uint RemUInt32(uint n, uint d)
Parameters
Returns
RemUInt64(ulong, ulong)
public static ulong RemUInt64(ulong n, ulong d)