Show / Hide Table of Contents

Class PositiveModuloLibrary

This extension class contains a function that returns the positive only modulo of a value.

Inheritance
System.Object
PositiveModuloLibrary
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: CarbideFunction.Wildtile
Syntax
public static class PositiveModuloLibrary

Methods

PositiveModulo(Int32, Int32)

Calculate the modulo for a given modulus.

It doesn't give strictly positive modulos - It will have the same sign as modulus. In most cases this is positive, hence the name.

var result = 7.PositiveModulo(4);
Assert.AreEqual(result, 3);
Assert.AreEqual(-5.PositiveModulo(2), 1);

Assert.AreEqual( 3.PositiveModulo(3), 0); Assert.AreEqual( 2.PositiveModulo(3), 2); Assert.AreEqual( 1.PositiveModulo(3), 1); Assert.AreEqual( 0.PositiveModulo(3), 0); Assert.AreEqual(-1.PositiveModulo(3), 2); Assert.AreEqual(-2.PositiveModulo(3), 1);

Declaration
public static int PositiveModulo(this int self, int modulus)
Parameters
Type Name Description
System.Int32 self
System.Int32 modulus
Returns
Type Description
System.Int32
In This Article
Generated by DocFX Version: 4.1.0 - click to show/hide other versions