Show / Hide Table of Contents

Class MathUtils

Provides math-related utility functions.

Inheritance
Object
MathUtils
Namespace: NanoByte.Common
Assembly: NanoByte.Common.dll
Syntax
public static class MathUtils : Object

Methods

EqualsTolerance(Double, Double, Double)

Compares two floating-point values for equality, allowing for a certain tolerance.

Declaration
public static bool EqualsTolerance(this double a, double b, double tolerance = 1E-05)
Parameters
Type Name Description
Double a
Double b
Double tolerance
Returns
Type Description
Boolean

EqualsTolerance(Single, Single, Single)

Compares two floating-point values for equality, allowing for a certain tolerance.

Declaration
public static bool EqualsTolerance(this float a, float b, float tolerance = 1E-05F)
Parameters
Type Name Description
Single a
Single b
Single tolerance
Returns
Type Description
Boolean

Modulo(Int32, Int32)

Calculates the mathematical modulo of a value.

Declaration
public static int Modulo(this int value, int modulo)
Parameters
Type Name Description
Int32 value
Int32 modulo
Returns
Type Description
Int32

Modulo(Int64, Int64)

Calculates the mathematical modulo of a value.

Declaration
public static long Modulo(this long value, long modulo)
Parameters
Type Name Description
Int64 value
Int64 modulo
Returns
Type Description
Int64

MultiplyAndRound(Size, SizeF)

Multiplies a Size with a SizeF and then rounds the components to integer values.

Declaration
public static Size MultiplyAndRound(this Size size, SizeF factor)
Parameters
Type Name Description
Size size
SizeF factor
Returns
Type Description
Size
In This Article
Back to top Copyright Bastian Eicher