Show / Hide Table of Contents

Class Math2

Simple calculation functions.

public static class Math2

Namespace: Au.More
Assembly: Au.dll
Inheritance
object
Math2

Methods

Name Description
AlignUp(int, uint)

If value is divisible by alignment, returns value. Else returns the nearest bigger number that is divisible by alignment.

AlignUp(uint, uint)

If value is divisible by alignment, returns value. Else returns the nearest bigger number that is divisible by alignment.

AngleFromXY(int, int)

Calculates angle degrees from coordinates x and y.

Distance(POINT, POINT)

Calculates distance between two points.

Distance(RECT, POINT)

Calculates distance between rectangle and point.

HiByte(ushort)

Gets bits 9-16 as byte. Like C macro HIBYTE.

HiShort(nint)

Gets bits 17-32 as short. Like C macro GET_Y_LPARAM.

HiWord(nint)

Gets bits 17-32 as ushort. Like C macro HIWORD.

LoByte(ushort)

Gets bits 1-8 as byte. Like C macro LOBYTE.

LoShort(nint)

Gets bits 1-16 as short. Like C macro GET_X_LPARAM.

LoWord(nint)

Gets bits 1-16 as ushort. Like C macro LOWORD.

MakeLparam(POINT)

Creates uint by placing (ushort)p.x in bits 1-16 and (ushort)p.y in bits 17-32. Returns it as nint, ready to use with Windows message API as lParam or wParam or return value. Like C macro MAKELONG, MAKEWPARAM, MAKELPARAM, MAKELRESULT.

MakeLparam(int, int)

Creates uint by placing (ushort)loWord in bits 1-16 and (ushort)hiWord in bits 17-32. Returns it as nint, ready to use with Windows message API as lParam or wParam or return value. Like C macro MAKELONG, MAKEWPARAM, MAKELPARAM, MAKELRESULT.

MakeLparam(uint, uint)

Creates uint by placing (ushort)loWord in bits 1-16 and (ushort)hiWord in bits 17-32. Returns it as nint, ready to use with Windows message API as lParam or wParam or return value. Like C macro MAKELONG, MAKEWPARAM, MAKELPARAM, MAKELRESULT.

MakeWord(int, int)

Creates ushort by placing (byte)loByte in bits 1-8 and (byte)hiByte in bits 9-16. Like C macro MAKEWORD.

MakeWord(uint, uint)

Creates ushort by placing (byte)loByte in bits 1-8 and (byte)hiByte in bits 9-16. Like C macro MAKEWORD.

MulDiv(int, int, int)

Returns number * multiply / divide. Multiplies without overflow and rounds up or down to the nearest integer.

NintToPOINT(nint)

Converts nint containing x and y coordinates to POINT.

PercentFromValue(double, double)

Calculates how many % of whole is part: 100 * part / whole.

PercentFromValue(int, int, bool)

Calculates how many % of whole is part: 100L * part / whole.

PercentToValue(double, double)

Returns percent % of whole: whole * percent / 100.

PercentToValue(int, int, bool)

Returns percent % of whole: (long)whole * percent / 100.

SwapBits(int, int, int, int)

Swaps two ranges of bits.

SwapBits(uint, int, int, int)

Swaps two ranges of bits.

Swap<T>(ref T, ref T)

Swaps values of two variables: T t = a; a = b; b = t;