Public API
InfiniteValueInfVal
struct
Infinite-precision value type. Represents digits × 10exponent.
Immutable on the public side. Implements IComparable,
IComparable<InfVal>, IEquatable<InfVal>.
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. 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. |
| InfVal(double value, int? precision = null) | Default precision: 17. |
| InfVal(decimal value, int? precision = null) | Default precision: 29. |
| 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, 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). |
| 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). |
| 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 (null falls back to the Configuration default). |
| 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. |
| 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 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. |
| +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. Throws DivideByZeroException if b is zero. |
| a % b | Modulo. Throws DivideByZeroException if b is zero. |
| ~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. |
| 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. |
(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. |
| (InfVal)string | Parse using the default formatter. |
| (InfVal)(string, int) | Parse and set precision. |
| (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) | Convert via string representation. Throws OverflowException 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.
| string Format(in InfVal value) | Convert an InfVal to its string representation. |
| void Format(in InfVal value, List<string> parts, int partCount = 0) | Fill parts with the pieces of the formatted value: the number first, then a unit, or an exponent marker and its digits. Concatenating them gives what Format returns. partCount of 0 or less asks for the natural split, a positive value for exactly that many pieces, up to InfValFormatHelper.maxPartCount (16). Has a default implementation putting the whole output in a single part, so implementing it is optional. |
| 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.
| IInfValFormatter formatter | The wrapped formatter instance. |
ManualFormatter
class
Fully explicit IInfValFormatter. Every formatting detail
is configurable. Use [Serializable] is already applied.
| int groupSize | Number of digits per unit level and group separator step. Default: 3 (k/M/G style). Use 4 for East Asian style (万/億/兆). |
| string[] unitsList | Suffix list applied at each power step (default: k, M, G, T, P, E, Z, Y). |
| int maxDisplayedDigits | Maximum digits to show, leading zeros of values below 1 included. The last displayed digit is rounded half away from zero. 0 = unlimited. Default: 8. |
| string decimalSeparator | Decimal point character(s). Default: ".". |
| string groupSeparator | Thousands separator character(s). Default: ",". |
| string exponentMarker | Marker for scientific notation. Default: "e". |
| bool addGroupSeparatorsBeforeDecimalPoint | Add thousands separators in the integer part. Default: true. |
| bool addGroupSeparatorsAfterDecimalPoint | Add thousands separators in the fractional part. Default: false. |
| bool forceAbbreviation | Always use a unit suffix or scientific notation. Default: false. |
| bool limitDisplayedDecimals | Turn on the maxDisplayedDecimals limit. Default: false. |
| int maxDisplayedDecimals | Maximum decimals to display, in the decimal part of the number or of the abbreviated mantissa, applied when limitDisplayedDecimals is true. Values needing more are rounded to fit, and values below 1 stay in fixed point instead of switching to a unit or scientific notation, as long as they fit in maxDisplayedDigits. 0 rounds to whole numbers. Default: 2. |
| bool keepTrailingZeros | Keep the trailing zeros of the decimal part, padding it up to maxDisplayedDecimals when that limit is set. Default: false. |
ScientificFormatter
class
IInfValFormatter that always produces scientific notation
(e.g. 1.23e+6). No unit suffixes or group separators.
| string decimalSeparator | Default: ".". |
| string exponentMarker | Default: "e". |
| int maxDisplayedDigits | Default: 8. |
| bool keepTrailingZeros | Default: 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.
| string alphabet | Source string for generating suffixes. Default: "abcdefghijklmnopqrstuvwxyz". |
| int maxDisplayedDigits | Default: 4. |
| string decimalSeparator | Default: ".". |
| string groupSeparator | Default: ",". |
| bool addGroupSeparatorsBeforeDecimalPoint | Default: false. |
| bool addGroupSeparatorsAfterDecimalPoint | Default: false. |
| bool limitDisplayedDecimals | Turn on the maxDisplayedDecimals limit. Default: false. |
| int maxDisplayedDecimals | Maximum decimals to display, in the decimal part of the number or of the abbreviated mantissa, applied when limitDisplayedDecimals is true. Values needing more are rounded to fit, and values below 1 stay in fixed point instead of switching to a unit or scientific notation, as long as they fit in maxDisplayedDigits. 0 rounds to whole numbers. Default: 2. |
| bool keepTrailingZeros | Default: 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.
| Culture culture | The culture. Default: CurrentCulture. |
| int maxDisplayedDigits | Default: 8. |
| bool addGroupSeparatorsBeforeDecimalPoint | Default: true. |
| bool addGroupSeparatorsAfterDecimalPoint | Default: false. |
| bool limitDisplayedDecimals | Turn on the maxDisplayedDecimals limit. Default: false. |
| int maxDisplayedDecimals | Maximum decimals to display, in the decimal part of the number or of the abbreviated mantissa, applied when limitDisplayedDecimals is true. Values needing more are rounded to fit, and values below 1 stay in fixed point instead of switching to a unit or scientific notation, as long as they fit in maxDisplayedDigits. 0 rounds to whole numbers. Default: 2. |
| bool keepTrailingZeros | Default: false. |
InfValFormatHelper
static classLow-level utilities for implementing IInfValFormatter. Provides full formatting, parsing, partial-input validation, culture helpers, and unit validation.
| string[] defaultExponentMarkers | Standard exponent markers accepted during parsing: { "e", "E" }. |
| const int maxPartCount | Highest part count the Format overloads filling a List<string> accept: 16. |
| 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, int maxDisplayedDecimals = -1) | Convert an InfVal to a string with full control. unitStep: 3 for k/M/G (default), 4 for East Asian 万/億. |
| void Format(in InfVal value, int maxDisplayedDigits, string[] unitsList, string decimalPoint, string groupSeparator, string exponentMarker, bool addGroupSepBefore, bool addGroupSepAfter, bool forceAbbreviation, bool keepTrailingZeros, List<string> parts, int partCount = 0, int unitStep = 3, int maxDisplayedDecimals = -1) | Same, filling parts with the pieces instead of returning one string. Throws ArgumentNullException if parts is null. |
| 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+"). |
| 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.
| 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.
| 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. |
| FormatterAsset formatter | Formatter override. Null falls back to the Configuration default. |
| ValidateType validateType | How invalid input is treated. Default: None. |
| Color validColor | Text color when the input is valid. Default: black. |
| Color invalidColor | Text color when the input is invalid. Default: red. |
| bool integerOnly | Treat non-integer values as invalid. Default: false. |
| ForceSign forceSign | Restrict to positive or negative values. Default: None. |
| bool nonZero | Treat zero as invalid. Default: false. |
| Selectable[] interactablesIfValid | UI Selectables enabled only when the input is valid. |
| bool redrawOnEndEdit | Replace typed text with a clean formatted representation on end edit. Default: true. |
| 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. |
| 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 classMath operations for InfVal, analogous to Mathf.
| 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 Round(in InfVal value, int decimals) | Round to a number of digits after the decimal point. 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|. |
| 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.
| 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.
| Type { InvariantCulture, CurrentCulture, SpecificCulture } | How the CultureInfo is determined. |
| Culture(Type type) | Create using InvariantCulture or CurrentCulture. |
| Culture(string name) | Create a SpecificCulture by name (e.g. "fr-FR"). |
| CultureInfo info | The underlying CultureInfo instance. |
| (CultureInfo)culture | Implicit conversion to CultureInfo via .info. |