PowerMultiple

References
[IoId("00000000-AE93-48D3-8C0B-0D2EA0ADE15A")] public struct PowerMultiple : IComparable<PowerMultiple>, IStorable
Represents an immutable number defined as the multiple of some power.

Constructors

PowerMultiple

#
public PowerMultiple(BigInteger coefficient, int radix, int exponent)
Create a new power multiple.
coefficient (BigInteger)Multiple of (radix^power).
radix (int)Radix (or base) of number.
exponent (int)Power (or exponent) of number.

PowerMultiple

#
public PowerMultiple(IReader reader)
reader (IReader)

Properties

Absolute

#
public PowerMultiple Absolute { get; }
Gets the absolute of this number.

Coefficient

#
public BigInteger Coefficient { get; }
Gets the multiple of Radix^Power.

Exponent

#
public int Exponent { get; }
Gets the power (or exponent) for this number.

Inverse

#
public PowerMultiple Inverse { get; }
Gets the inverse (one-over) of this number. This operation is usually approximate, but will attempt to find an exact solution up to 32 radix-orders-of-magnitude down from the implied inverse exponent.

IsInteger

#
public bool IsInteger { get; }
Gets whether this value represents a whole number.

IsNegative

#
public bool IsNegative { get; }
Gets whether this value is negative.

IsOne

#
public bool IsOne { get; }
Gets whether this value is equal to one.

IsPositive

#
public bool IsPositive { get; }
Gets whether this value is negative. Note that zero is not considered positive.

IsZero

#
public bool IsZero { get; }
Gets whether this value is equal to zero.

MinusOne

#
public static PowerMultiple MinusOne { get; }
Gets the negative one constant.

Negative

#
public PowerMultiple Negative { get; }
Gets the negative of this number.

One

#
public static PowerMultiple One { get; }
Gets the one constant.

Radix

#
public int Radix { get; }
Gets the base of the power.

Sign

#
public int Sign { get; }
Gets the sign indicator -1 = negative, 0 = zero, +1 = positive.

Zero

#
public static PowerMultiple Zero { get; }
Gets the zero constant.

Methods

CompareTo

#
public int CompareTo(PowerMultiple other)
Compare two power multiples.
other (PowerMultiple)

DecimalPart

#
public PowerMultiple DecimalPart()
Return the decimal part of this number. This is basically the number minus the nearest smaller integer.

Expand

#
public PowerMultiple Expand(int exponent)
Decrease the exponent and raise the coefficient of this number without changing its magnitude.
exponent (int)New exponent, must be smaller than or equal to the current exponent.
Expanded number.

FromFloatingPoint

#
public static PowerMultiple FromFloatingPoint(double number, int decimals, int radix)
Convert a floating point value into a power multiple.
number (double)Value.
decimals (int)Decimal places to consider.
radix (int)Radix base.
Power multiple representing the floating point number.

FromFloatingPoint

#
public static PowerMultiple FromFloatingPoint(double number, int decimals)
Convert a floating point value into a power multiple base 10.
number (double)Value.
decimals (int)Decimal places to consider.
Power multiple representing the floating point number.

IntegralPart

#
public PowerMultiple IntegralPart()
Return the integral part of this number.

Rebase

#
public PowerMultiple Rebase(int radix)
Rebase this number. Note that this method will return approximate values under certain conditions.
radix (int)New radix.
Rebased number.

Reduce

#
public PowerMultiple Reduce()
Create the simplest possible version of this number, ie. using the highest possible power.

Round

#
public PowerMultiple Round(int digits)
Round this number down to a fixed number of significant coefficient digits. Rounding is only exact if the Radix equals 10, otherwise some inaccuracies will be introduced.
digits (int)Number of digits.
Rounded number.

Store

#
public void Store(IWriter writer)
writer (IWriter)
Store

ToDouble

#
public double ToDouble()
Gets the double representation for this power multiple. Note that very large and very small powers fall outside the double numeric range.
Double representation of power multiple.

ToInteger

#
public BigInteger ToInteger()
Gets the integer representation for this power multiple. If this multiple cannot be represented by an exact integer, an approximate value is returned.
Integer representation of power multiple.

ToString

#
public override string ToString()
Returns a string that represents the current value.
A string that represents the current object.

ToString

#
public string ToString(NumberFormat integerFormat, NumberFormat doubleFormat)
Returns a string that represents the current value.
integerFormat (NumberFormat)Formatter to use for integers.
doubleFormat (NumberFormat)Formatter to use for non-integers.
A string that represents the current object.

TryParse

#
public static bool TryParse(string text, out PowerMultiple pm)
Try to convert a string representation back into a power multiple.
text (string)String to convert.
pm (out PowerMultiple)Power multiple on success.
True if string could be parsed.

Operators

OperationResultDescription
PowerMultiple+PowerMultiplePowerMultipleAdd two power multiples together. Multiples must share the same radix.
PowerMultiple/PowerMultiplePowerMultipleMultiply two power multiples together. Multiples must share the same radix.
PowerMultiple>PowerMultipleboolCompare two numbers for less-than.
PowerMultiple<PowerMultipleboolCompare two numbers for less-than.
PowerMultiple*PowerMultiplePowerMultipleMultiply two power multiples together. Multiples must share the same radix.
PowerMultiple-PowerMultiplePowerMultipleSubtract two power multiples. Multiples must share the same radix.
-PowerMultiplePowerMultipleCreate the negative of a power multiple.
+PowerMultiplePowerMultiplePositive indicator. This operator does nothing.

Convertors

OperationResultDescription
implicitBigIntegerPowerMultipleConvert a big integer into a power multiple.
implicitdoublePowerMultipleConvert a double precision floating point number into a power multiple. This automatic converter assumes six decimal places of accuracy, if you want custom control over the accuracy, use the FromFloatingPoint() method.
implicitintPowerMultipleConvert an integer into a power multiple.
implicitlongPowerMultipleConvert a long integer into a power multiple.