|
|
|
@ -42,9 +42,7 @@ namespace MathNet.Numerics |
|
|
|
/// <summary>
|
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
|
/// </summary>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static double Modulus(double dividend, double divisor) |
|
|
|
{ |
|
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
|
@ -53,9 +51,7 @@ namespace MathNet.Numerics |
|
|
|
/// <summary>
|
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
|
/// </summary>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static float Modulus(float dividend, float divisor) |
|
|
|
{ |
|
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
|
@ -64,9 +60,7 @@ namespace MathNet.Numerics |
|
|
|
/// <summary>
|
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
|
/// </summary>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static int Modulus(int dividend, int divisor) |
|
|
|
{ |
|
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
|
@ -75,9 +69,7 @@ namespace MathNet.Numerics |
|
|
|
/// <summary>
|
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
|
/// </summary>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static long Modulus(long dividend, long divisor) |
|
|
|
{ |
|
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
|
@ -86,9 +78,7 @@ namespace MathNet.Numerics |
|
|
|
/// <summary>
|
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
|
/// </summary>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static BigInteger Modulus(BigInteger dividend, BigInteger divisor) |
|
|
|
{ |
|
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
|
@ -97,9 +87,7 @@ namespace MathNet.Numerics |
|
|
|
/// <summary>
|
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
|
/// </summary>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static double Remainder(double dividend, double divisor) |
|
|
|
{ |
|
|
|
return dividend%divisor; |
|
|
|
@ -108,9 +96,7 @@ namespace MathNet.Numerics |
|
|
|
/// <summary>
|
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
|
/// </summary>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static float Remainder(float dividend, float divisor) |
|
|
|
{ |
|
|
|
return dividend%divisor; |
|
|
|
@ -119,9 +105,7 @@ namespace MathNet.Numerics |
|
|
|
/// <summary>
|
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
|
/// </summary>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static int Remainder(int dividend, int divisor) |
|
|
|
{ |
|
|
|
return dividend%divisor; |
|
|
|
@ -130,9 +114,7 @@ namespace MathNet.Numerics |
|
|
|
/// <summary>
|
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
|
/// </summary>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static long Remainder(long dividend, long divisor) |
|
|
|
{ |
|
|
|
return dividend%divisor; |
|
|
|
@ -141,9 +123,7 @@ namespace MathNet.Numerics |
|
|
|
/// <summary>
|
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
|
/// </summary>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static BigInteger Remainder(BigInteger dividend, BigInteger divisor) |
|
|
|
{ |
|
|
|
return dividend%divisor; |
|
|
|
@ -154,9 +134,7 @@ namespace MathNet.Numerics |
|
|
|
/// </summary>
|
|
|
|
/// <param name="number">The number to very whether it's even.</param>
|
|
|
|
/// <returns>True if and only if it is an even number.</returns>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static bool IsEven(this int number) |
|
|
|
{ |
|
|
|
return (number & 0x1) == 0x0; |
|
|
|
@ -167,9 +145,7 @@ namespace MathNet.Numerics |
|
|
|
/// </summary>
|
|
|
|
/// <param name="number">The number to very whether it's even.</param>
|
|
|
|
/// <returns>True if and only if it is an even number.</returns>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static bool IsEven(this long number) |
|
|
|
{ |
|
|
|
return (number & 0x1) == 0x0; |
|
|
|
@ -180,9 +156,7 @@ namespace MathNet.Numerics |
|
|
|
/// </summary>
|
|
|
|
/// <param name="number">The number to very whether it's odd.</param>
|
|
|
|
/// <returns>True if and only if it is an odd number.</returns>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static bool IsOdd(this int number) |
|
|
|
{ |
|
|
|
return (number & 0x1) == 0x1; |
|
|
|
@ -193,9 +167,7 @@ namespace MathNet.Numerics |
|
|
|
/// </summary>
|
|
|
|
/// <param name="number">The number to very whether it's odd.</param>
|
|
|
|
/// <returns>True if and only if it is an odd number.</returns>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static bool IsOdd(this long number) |
|
|
|
{ |
|
|
|
return (number & 0x1) == 0x1; |
|
|
|
@ -206,9 +178,7 @@ namespace MathNet.Numerics |
|
|
|
/// </summary>
|
|
|
|
/// <param name="number">The number to very whether it's a power of two.</param>
|
|
|
|
/// <returns>True if and only if it is a power of two.</returns>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static bool IsPowerOfTwo(this int number) |
|
|
|
{ |
|
|
|
return number > 0 && (number & (number - 1)) == 0x0; |
|
|
|
@ -219,9 +189,7 @@ namespace MathNet.Numerics |
|
|
|
/// </summary>
|
|
|
|
/// <param name="number">The number to very whether it's a power of two.</param>
|
|
|
|
/// <returns>True if and only if it is a power of two.</returns>
|
|
|
|
#if !NET40
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
#endif
|
|
|
|
public static bool IsPowerOfTwo(this long number) |
|
|
|
{ |
|
|
|
return number > 0 && (number & (number - 1)) == 0x0; |
|
|
|
|