InfVal

struct

Infinite-precision value type. Represents digits × 10exponent. Immutable on the public side. Implements IComparable, IComparable<InfVal>, IEquatable<InfVal>.

Constructors
The optional precision parameter sets the number of significant digits. Must be > 0. When omitted, use the max digit count for the type;
InfVal(InfVal value, int? precision = null) From another InfVal.
InfVal(BigInteger value, int? precision = null) From a BigInteger.
InfVal(string valStr, int? precision = null) Parsed from a string using the default formatter.
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.
InfVal(double value, int? precision = null) Default precision: 17.
InfVal(decimal value, int? precision = null) Default precision: 29.
Static Methods
InfVal ManualFactory(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.
InfVal Parse(string str, IInfValFormatter formatter) Parse using a specific formatter. Throws FormatException if invalid.
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.
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 exponent < 0.
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(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.
string ToString() Format using the Configuration default formatter. Falls back to ToDebugString() if no default is configured.
string ToDebugString() Returns "(digits, exponent)": a raw representation useful for debugging.
bool Equals(InfVal other) Value equality.
bool Equals(object obj) Value equality with any object.
int GetHashCode() Hash code based on digits and exponent.
int CompareTo(InfVal other) Returns −1, 0, or 1.
int CompareTo(object obj) Compares with any type castable to InfVal. Throws ArgumentException for incompatible types.
Operators: Arithmetic
+aIdentity.
-aNegation.
a + bAddition. Result precision = max(a.precision, b.precision).
a - bSubtraction. Result precision = max(a.precision, b.precision).
a * bMultiplication. Result precision = max(a.precision, b.precision).
a / bDivision. Throws DivideByZeroException if b is zero.
a % bModulo. Throws DivideByZeroException if b is zero.
Operators: Bitwise
Bitwise operators require exponent == 0. Throws InvalidOperationException otherwise.
~aBitwise NOT.
a & bBitwise AND.
a | bBitwise OR.
a ^ bBitwise XOR.
a << nLeft shift by n bits.
a >> nRight shift by n bits.
Operators: Comparison
a == bValue equality.
a != bValue inequality.
a < bLess than.
a > bGreater than.
a <= bLess than or equal.
a >= bGreater 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, ushortSmall integer types.
int, uint, long, ulongStandard integer types.
float, double, decimalFloating-point types.
BigIntegerArbitrary-precision integer.
InfValCopy.
(T value, int precision)Any of the above as a tuple, setting precision explicitly.
Explicit Casts: to InfVal
(InfVal)stringParse using the default formatter.
(InfVal)(string, int)Parse and set precision.
Explicit Casts: from InfVal
(BigInteger)ivTruncates to integer part (ToExponent(0).digits).
(sbyte) (byte) (short) (ushort)
(int) (uint) (long) (ulong)
Cast through BigInteger; may overflow.
(float) (double) (decimal)Convert via string representation; returns 0 on overflow.

IInfValFormatter

interface

Implement this interface to define how an InfVal is formatted to and parsed from a string. Mark the implementing class [Serializable] so it can be used inside a FormatterAsset.

Methods
string Format(in InfVal value) Convert an InfVal to its string representation.
bool TryParse(string text, out InfVal result) Try to convert a string to an InfVal. Return false (and set result to default) if the string is not a valid complete number.
bool IsValidPartialInput(string text) Return true if the text is either fully valid or a valid partial input that could still become valid (e.g. "-", "1.", "1e+"). Used by InfValInputField in DisallowInvalid mode.

FormatterAsset

ScriptableObject

A ScriptableObject wrapping an IInfValFormatter so it can be referenced in the inspector and shared across components. Create via Assets > Create > Infinite Value > Formatter.

Properties
IInfValFormatter formatter The wrapped formatter instance.

ManualFormatter

class

Fully explicit IInfValFormatter. Every formatting detail is configurable. Use [Serializable] is already applied.

Public Fields
int groupSizeNumber of digits per unit level and group separator step. Default: 3 (k/M/G style). Use 4 for East Asian style (万/億/兆).
string[] unitsListSuffix list applied at each power step (default: k, M, G, T, P, E, Z, Y).
int maxDisplayedDigitsMaximum digits to show. 0 = unlimited. Default: 8.
string decimalSeparatorDecimal point character(s). Default: ".".
string groupSeparatorThousands separator character(s). Default: ",".
string exponentMarkerMarker for scientific notation. Default: "e".
bool addGroupSeparatorsBeforeDecimalPointAdd thousands separators in the integer part. Default: true.
bool addGroupSeparatorsAfterDecimalPointAdd thousands separators in the fractional part. Default: false.
bool forceAbbreviationAlways use a unit suffix or scientific notation. Default: false.
bool keepTrailingZerosPad decimals with zeros up to maxDisplayedDigits. Default: false.

ScientificFormatter

class

IInfValFormatter that always produces scientific notation (e.g. 1.23e+6). No unit suffixes or group separators.

Public Fields
string decimalSeparatorDefault: ".".
string exponentMarkerDefault: "e".
int maxDisplayedDigitsDefault: 8.
bool keepTrailingZerosDefault: false.

AlphabeticFormatter

class

IInfValFormatter for idle-game style notation with letter suffixes: 1.23a, 4.56b, ..., 1.00aa, etc. Suffixes are generated from a configurable alphabet and cached automatically.

Public Fields
string alphabetSource string for generating suffixes. Default: "abcdefghijklmnopqrstuvwxyz".
int maxDisplayedDigitsDefault: 4.
string decimalSeparatorDefault: ".".
string groupSeparatorDefault: ",".
bool addGroupSeparatorsBeforeDecimalPointDefault: false.
bool addGroupSeparatorsAfterDecimalPointDefault: false.
bool keepTrailingZerosDefault: false.

CultureFormatter

class

IInfValFormatter that derives separators from a C# CultureInfo. Automatically uses native East Asian units (万/億/兆/京, 만/억/조/경, 万/亿/兆) with 4-digit stepping for ja-*, ko-*, and zh-* locales; Western units (k/M/G/...) with 3-digit stepping for all others.

Public Fields
Culture cultureThe culture. Default: CurrentCulture.
int maxDisplayedDigitsDefault: 8.
bool addGroupSeparatorsBeforeDecimalPointDefault: true.
bool addGroupSeparatorsAfterDecimalPointDefault: false.
bool keepTrailingZerosDefault: false.

InfValFormatHelper

static class

Low-level utilities for implementing IInfValFormatter. Provides full formatting, parsing, partial-input validation, culture helpers, and unit validation.

Static Fields
string[] defaultExponentMarkers Standard exponent markers accepted during parsing: { "e", "E" }.
Static Methods: Formatting
string Format(in InfVal value, int maxDisplayedDigits, string[] unitsList, string decimalPoint, string groupSeparator, string exponentMarker, bool addGroupSepBefore, bool addGroupSepAfter, bool forceAbbreviation, bool keepTrailingZeros, int unitStep = 3) Convert an InfVal to a string with full control. unitStep: 3 for k/M/G (default), 4 for East Asian 万/億.
Static Methods: Parsing
bool TryParse(string text, string[] unitsList, string decimalPoint, string groupSeparator, string[] exponentMarkers, out InfVal result, int unitStep = 3) Try to parse a string. Returns false on failure.
InfVal Parse(string text, string[] unitsList, string decimalPoint, string groupSeparator, string[] exponentMarkers, int unitStep = 3) Parse a string. Throws FormatException on failure.
bool IsValidPartialInput(string text, string[] unitsList, string decimalPoint, string groupSeparator, string[] exponentMarkers, int unitStep = 3) True if the text is fully valid or is a valid partial input (e.g. "-", "1.", "1e+").
Static Methods: Culture & Validation
string GetDecimalSeparator(CultureInfo culture) Returns the decimal separator for the culture. Falls back to "." if null.
string GetGroupSeparator(CultureInfo culture) Returns the group separator for the culture. Falls back to "," if null.
bool AreUnitsValid(string[] unitsList) True if the array is a valid list of unit suffixes. Logs errors to the Unity console on invalid entries.

Configuration

ScriptableObject

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 Absolute path to the Infinite Value package folder, derived automatically from the source file location.
IInfValFormatter defaultFormatter The formatter used by InfVal.ToString(), Parse(), and TryParse() when no formatter is specified explicitly.

InfValInputField

MonoBehaviour

Converts a InputField or TMP_InputField component on the same GameObject into an InfVal input field. Add via Add Component > UI > InfVal Input Field Converter.

Enums
ValidateType { None, ChangeColor, DisallowInvalid } How invalid input is handled. ChangeColor tints the text; DisallowInvalid blocks characters that would make the input invalid.
ForceSign { None, Positive, Negative } Force the value to be positive, negative, or unconstrained.
Public Fields
FormatterAsset formatterFormatter override. Null falls back to the Configuration default.
ValidateType validateTypeHow invalid input is treated. Default: None.
Color validColorText color when the input is valid. Default: black.
Color invalidColorText color when the input is invalid. Default: red.
bool integerOnlyTreat non-integer values as invalid. Default: false.
ForceSign forceSignRestrict to positive or negative values. Default: None.
bool nonZeroTreat zero as invalid. Default: false.
Selectable[] interactablesIfValidUI Selectables enabled only when the input is valid.
bool redrawOnEndEditReplace typed text with a clean formatted representation on end edit. Default: true.
Properties
IInfValFormatter activeFormatter The formatter in use: the assigned FormatterAsset's formatter if set, otherwise Configuration.defaultFormatter.
InfVal value Get or set the current InfVal. Setting it updates the displayed text.
bool isValid Whether the current value passes all validation constraints.
Component target The underlying InputField or TMP_InputField component.
InputField inputField Target cast to InputField; null if target is a TMP_InputField.
TMP_InputField TMP_inputField Target cast to TMP_InputField; null if target is an InputField.
Methods
T GetTarget<T>() Return the target component cast to type T; null if the cast fails.
void FindTargetComponent() Search for an InputField or TMP_InputField on the same GameObject and initialize it. Called automatically on Reset and Awake.
string FormatInfValToString(in InfVal value) Format an InfVal using this component's active formatter.

MathInfVal

static class

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 to significantDigits significant digits.
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.
InfVal PreviousPowerOfTwo(in InfVal value)Previous power of two ≤ value.
InfVal Repeat(in InfVal value, in InfVal length)Loop value so it is never < 0 or ≥ length. 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).
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.
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|.
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. Throws ArgumentException if n = 0, or if value < 0 and n is even.
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]. Throws ArgumentException if min > max.

InterpolateInfVal

static class

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.

Culture

class

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.