Value type
Infinite-precision value type. Represents digits × 10exponent.
Immutable on the public side. Implements IComparable,
IComparable<InfVal>, IEquatable<InfVal>, IConvertible.
Constructors
The optional precision parameter sets the number of significant digits.
When omitted, a primitive type uses the default precision listed below, and an InfVal, a BigInteger or a string keeps the digits it holds.
Throws ArgumentException if precision ≤ 0.
| InfVal(in InfVal value, int? precision = null) |
From another InfVal. |
| InfVal(in BigInteger value, int? precision = null) |
From a BigInteger. |
| InfVal(string valStr, int? precision = null) |
Parsed from a string using the default formatter. Invalid input yields 0. |
| InfVal(sbyte value, int? precision = null) |
Default precision: 3. |
| InfVal(byte value, int? precision = null) |
Default precision: 3. |
| InfVal(short value, int? precision = null) |
Default precision: 5. |
| InfVal(ushort value, int? precision = null) |
Default precision: 5. |
| InfVal(int value, int? precision = null) |
Default precision: 10. |
| InfVal(uint value, int? precision = null) |
Default precision: 10. |
| InfVal(long value, int? precision = null) |
Default precision: 19. |
| InfVal(ulong value, int? precision = null) |
Default precision: 20. |
| InfVal(float value, int? precision = null) |
Default precision: 9. Throws ArgumentException if value is NaN or infinity. |
| InfVal(double value, int? precision = null) |
Default precision: 17. Throws ArgumentException if value is NaN or infinity. |
| InfVal(decimal value, int? precision = null) |
Default precision: 29. |
Static Methods
| InfVal ManualFactory(in BigInteger digits, int exponent) |
Create an InfVal by setting its internal fields directly, without the normalization that constructors apply. Use when you need exact control over digits and exponent. |
| InfVal Parse(string str) |
Parse using the default formatter. Throws FormatException if invalid, or InvalidOperationException if no default formatter is configured. |
| InfVal Parse(string str, IInfValFormatter formatter) |
Parse using a specific formatter (null falls back to the Configuration default). Throws FormatException if invalid, or InvalidOperationException if formatter is null and no default is configured. |
| bool TryParse(string str, out InfVal result) |
Try parse using the default formatter. Returns false on failure; never throws. |
| bool TryParse(string str, IInfValFormatter formatter, out InfVal result) |
Try parse using a specific formatter (null falls back to the Configuration default). |
Properties
| BigInteger digits |
The full digit integer. Value = digits × 10exponent. |
| int exponent |
The exponent. Setting it adjusts digits to preserve the represented value; if the shift exceeds current precision, digits are zeroed. |
| int precision |
Count of significant digits. |
| bool isInteger |
True if the value has no fractional part (can be true even with a negative exponent if all fractional digits are zero). |
| bool isZero |
True if the value equals 0. |
| bool isOne |
True if the value equals 1. |
| bool isEven |
True if the value is even. Throws InvalidOperationException if the value is not an integer. |
| bool isPowerOfTwo |
True if the value is a power of two. |
| int sign |
Sign of the value: 1 (positive), 0 (zero), or −1 (negative). |
Methods
| InfVal ToExponent(int exponent, bool raw = false) |
Return with a different exponent. By default adjusts digits to preserve the value. If raw = true, sets the exponent directly (shifts the decimal point, changing the value). Equivalent to MovePointLeft / MovePointRight. |
| InfVal ToDigits(in BigInteger digits) |
Return with different digits, keeping the current exponent. |
| InfVal ToPrecision(int precision) |
Return with a different precision by adjusting the exponent. Throws ArgumentException if precision ≤ 0. |
| InfVal RemoveTrailingZeros() |
Return with all trailing digit zeros removed. Does not change the value. |
| InfVal MovePointLeft(int move) |
Shift the decimal point left by move places. Changes the value. |
| InfVal MovePointRight(int move) |
Shift the decimal point right by move places. Changes the value. |
| void Deconstruct(out BigInteger digits, out int exponent) |
Deconstruct into digits and exponent. Supports tuple assignment: (BigInteger d, int e) = iv; |
| string ToString(IInfValFormatter formatter) |
Format using a specific formatter (null falls back to the Configuration default). Falls back to ToDebugString() if neither is set. |
| void Format(IInfValFormatter formatter, List<string> parts, int partCount = 0) |
Fill parts with the pieces of the formatted value (null formatter falls back to the Configuration default). Throws ArgumentNullException if parts is null, or ArgumentOutOfRangeException if partCount is above 16. |
| void Format(List<string> parts, int partCount = 0) |
Same, using the Configuration default formatter. |
| string ToString() |
Format using the Configuration default formatter. Falls back to ToDebugString() if no default is configured. |
| string ToString(IFormatProvider provider) |
Same as ToString(). The provider is ignored; pass a CultureFormatter to ToString(IInfValFormatter) for culture-aware output. |
| string ToDebugString() |
Returns "(digits, exponent)", a raw representation useful for debugging. |
| bool Equals(InfVal other) |
Value equality. |
| bool Equals(object obj) |
Value equality. False if obj is not an InfVal. |
| int GetHashCode() |
Hash code of the value: equal values stored at different precisions (5 and 5.0) hash the same. |
| int CompareTo(InfVal other) |
Returns −1, 0, or 1. |
| int CompareTo(object obj) |
Compares with an InfVal or any type castable to InfVal. Throws ArgumentException for incompatible types. |
Operators: Arithmetic
| +a | Identity. |
| -a | Negation. |
| a + b | Addition. Result precision = max(a.precision, b.precision). |
| a - b | Subtraction. Result precision = max(a.precision, b.precision). |
| a * b | Multiplication. Result precision = max(a.precision, b.precision). |
| a / b | Division. Result precision = max(a.precision, b.precision). Throws DivideByZeroException if b is zero. |
| a % b | Modulo. Result precision = max(a.precision, b.precision). Throws DivideByZeroException if b is zero. |
Operators: Bitwise
Bitwise and shift operators require an integer value, whatever its exponent. The result keeps the precision of the more precise operand, or more when it has more digits. Throws InvalidOperationException otherwise.
| ~a | Bitwise NOT. |
| a & b | Bitwise AND. |
| a | b | Bitwise OR. |
| a ^ b | Bitwise XOR. |
| a << n | Left shift by n bits. |
| a >> n | Right shift by n bits. |
Operators: Comparison
| a == b | Value equality. |
| a != b | Value inequality. |
| a < b | Less than. |
| a > b | Greater than. |
| a <= b | Less than or equal. |
| a >= b | Greater than or equal. |
Implicit Casts: to InfVal
All numeric primitives, BigInteger, and InfVal itself convert implicitly. A (value, precision) tuple overload exists for every type below.
| sbyte, byte, short, ushort | Small integer types. |
| int, uint, long, ulong | Standard integer types. |
| float, double, decimal | Floating-point types. |
| BigInteger | Arbitrary-precision integer. |
| InfVal | Copy. |
| (T value, int precision) | Any of the above as a tuple, setting precision explicitly. |
Explicit Casts: to InfVal
| (InfVal)string | Parse using the default formatter. |
| (InfVal)(string, int) | Parse and set precision. |
Explicit Casts: from InfVal
| (BigInteger)iv | Truncates to integer part (ToExponent(0).digits). |
(sbyte) (byte) (short) (ushort) (int) (uint) (long) (ulong) | Cast through BigInteger. Throws OverflowException on overflow. |
| (float) (double) (decimal) | float and double: the nearest value, ties to even. decimal: rounded to its 28 or 29 digits. Throws OverflowException on overflow. |
Formatting
Serializable wrapper around CultureInfo so it can be stored in the inspector
and serialized with the scene. Used by CultureFormatter.
Implicitly converts to CultureInfo.
Enum
| Type { InvariantCulture, CurrentCulture, SpecificCulture } |
How the CultureInfo is determined. |
Constructors
| Culture(Type type) |
Create using InvariantCulture or CurrentCulture. |
| Culture(string name) |
Create a SpecificCulture by name (e.g. "fr-FR"). |
Properties
| CultureInfo info |
The underlying CultureInfo instance. |
Implicit Cast
| (CultureInfo)culture |
Implicit conversion to CultureInfo via .info. |
Math
Math operations for InfVal, analogous to Mathf.
Static Methods
| InfVal Abs(in InfVal value) | Absolute value. |
| bool Approximately(in InfVal a, in InfVal b, int significantDigits) | True if a and b are equal when both rounded half away from zero to significantDigits significant digits. Throws ArgumentException if significantDigits <= 0. |
| InfVal Clamp(in InfVal value, in InfVal min, in InfVal max) | Clamp between min and max (both inclusive). |
| InfVal Clamp01(in InfVal value) | Clamp between 0 and 1. |
| InfVal ClosestPowerOfTwo(in InfVal value) | Nearest power of two. |
| InfVal NextPowerOfTwo(in InfVal value) | Next power of two ≥ value: 1 for a value up to 1, 0 for a negative value. |
| InfVal PreviousPowerOfTwo(in InfVal value) | Previous power of two ≤ value: 0 for a value below 1. |
| InfVal Repeat(in InfVal value, in InfVal length) | Loop value so it is never < 0 or ≥ length. With a negative length, the result lies in (length, 0], as Mathf.Repeat. Throws ArgumentException if length is zero. |
| InfVal PingPong(in InfVal value, in InfVal length) | Oscillate between 0 and length. Throws ArgumentException if length is zero. |
| InfVal DeltaAngle(in InfVal current, in InfVal target) | Shortest difference between two angles (degrees), in (−180, 180] as Mathf.DeltaAngle. |
| double Log(in InfVal value) | Natural logarithm. |
| double Log(in InfVal value, double logBase) | Logarithm in a specified base. |
| double Log10(in InfVal value) | Base-10 logarithm. |
| InfVal Floor(in InfVal value) | Largest integer ≤ value. |
| InfVal Ceil(in InfVal value) | Smallest integer ≥ value. |
| InfVal Round(in InfVal value) | Round to the nearest integer, halves away from zero. Result has the same exponent as the input. |
| InfVal Round(in InfVal value, int decimals) | Round to a number of digits after the decimal point, halves away from zero. A negative decimals rounds to tens, hundreds, and so on. Result has the same exponent as the input. |
| InfVal Truncate(in InfVal value) | Integer part (truncates toward zero). Result has the same exponent as the input. |
| InfVal DecimalPart(in InfVal value) | Fractional part. |
| InfVal Max(in InfVal a, in InfVal b) | Larger of two values. |
| InfVal Max(params InfVal[] values) | Largest of any number of values. Throws ArgumentException if empty. |
| InfVal Min(in InfVal a, in InfVal b) | Smaller of two values. |
| InfVal Min(params InfVal[] values) | Smallest of any number of values. Throws ArgumentException if empty. |
| int MaxExponent(in InfVal a, in InfVal b) | Higher exponent of the two. |
| int MaxExponent(params InfVal[] values) | Highest exponent among all values. Throws ArgumentException if empty. |
| int MinExponent(in InfVal a, in InfVal b) | Lower exponent of the two. |
| int MinExponent(params InfVal[] values) | Lowest exponent among all values. Throws ArgumentException if empty. |
| int MaxPrecision(in InfVal a, in InfVal b) | Higher precision of the two. |
| int MaxPrecision(params InfVal[] values) | Highest precision among all values. Throws ArgumentException if empty. |
| int MinPrecision(in InfVal a, in InfVal b) | Lower precision of the two. |
| int MinPrecision(params InfVal[] values) | Lowest precision among all values. Throws ArgumentException if empty. |
| InfVal Pow(in InfVal value, int power, bool conservePrecision = true) | Raise to an integer power. Negative power computes 1/value^|power|. With conservePrecision false, a positive power returns the exact result. Throws DivideByZeroException for a zero value and a negative power. |
| InfVal Sqrt(in InfVal value, bool conservePrecision = true) | Square root. Throws ArgumentException if value < 0. |
| InfVal NthRoot(in InfVal value, int n, bool conservePrecision = true) | Nth root, truncated. A negative n gives the reciprocal of the root. Throws ArgumentException if n = 0, or if value < 0 and n is even. Throws DivideByZeroException for a zero value and a negative n. |
| InfVal GreatestCommonDivisor(in InfVal a, in InfVal b) | GCD of two values. |
| InfVal RandomRange(in InfVal min, in InfVal max) | Uniformly random value in [min, max], with as many decimals as the bound that has the most. A value built from an integer type is padded with decimals to its type's default precision. Throws ArgumentException if min > max. |
| InfVal RandomIntegerRange(in InfVal min, in InfVal max) | Uniformly random integer in [min, max], with at least the precision of the more precise bound. Throws ArgumentException if no integer lies between min and max. |
Interpolation methods for InfVal. The clamped parameter (default
true) clamps t to [0, 1]. The Angle variants
wrap correctly around 360 degrees using MathInfVal.DeltaAngle.
Static Methods
| InfVal Linear(in InfVal min, in InfVal max, float t, bool clamped = true) | Linear interpolation. |
| InfVal SmoothStep(in InfVal min, in InfVal max, float t, bool clamped = true) | Smooth-step interpolation (ease in and out). |
| InfVal EaseIn(in InfVal min, in InfVal max, float t, float easePower, bool clamped = true) | Ease-in interpolation. easePower controls the curve strength. |
| InfVal EaseOut(in InfVal min, in InfVal max, float t, float easePower, bool clamped = true) | Ease-out interpolation. |
| InfVal EaseInAndOut(in InfVal min, in InfVal max, float t, float easePower, bool clamped = true) | Ease-in-and-out interpolation. |
| float InverseLinear(in InfVal min, in InfVal max, in InfVal value) | Inverse linear: returns the t that would produce value. Throws ArgumentException if min == max. |
| InfVal LinearAngle(in InfVal minAngle, in InfVal maxAngle, float t, bool clamped = true) | Linear interpolation that wraps around 360 degrees. |
| InfVal SmoothStepAngle(in InfVal minAngle, in InfVal maxAngle, float t, bool clamped = true) | SmoothStep that wraps around 360 degrees. |
| InfVal EaseInAngle(in InfVal minAngle, in InfVal maxAngle, float t, float easePower, bool clamped = true) | EaseIn that wraps around 360 degrees. |
| InfVal EaseOutAngle(in InfVal minAngle, in InfVal maxAngle, float t, float easePower, bool clamped = true) | EaseOut that wraps around 360 degrees. |
| InfVal EaseInAndOutAngle(in InfVal minAngle, in InfVal maxAngle, float t, float easePower, bool clamped = true) | EaseInAndOut that wraps around 360 degrees. |
Configuration
Project-wide settings for Infinite Value. Asset path:
Assets/Resources/Infinite Value Configuration. Opened via
Tools > Infinite Value > Configuration. Created automatically on
first domain reload if missing.
Static Properties
| Configuration asset |
The loaded Configuration asset instance. |
| string folderPath |
Project-relative path to the Infinite Value folder (for example Assets/Infinite Value), derived from the source file location. |
| IInfValFormatter defaultFormatter |
The formatter used by InfVal.ToString(), Parse(), and TryParse() when no formatter is specified explicitly. |
UI