Infinite Value

InfVal is an arbitrary-precision number type for Unity.
It stores any integer or decimal value and behaves like a primitive: full arithmetic, comparison, and bitwise operators, implicit casts from all numeric types, and direct inspector support.
Designed for real-time use and fully serializable.
Perfect for incremental games, RPGs, or any system where standard numeric types overflow or lose precision.
Features
- Arbitrary precision: integer or decimal with any digit count; values up to ~±10^4,294,967,295 with precision down to 10^−2,147,483,648
- Primitive-like API: arithmetic (
+,-,*,/,%), bitwise, and comparison operators; implicit casts from all numeric primitives - Formatter system: 4 built-in formatters (Manual, Scientific, Alphabetic, Culture-aware with native East Asian units) and a custom formatter interface; assign formatters project-wide or per component
- Inspector drawer: edit values directly, access raw digits and exponent, call transform methods with one click, and view all read-only properties, all sections configurable
- Input field component:
InfValInputFieldturns anyInputFieldorTMP_InputFieldinto anInfValfield with validation modes, sign constraints, and per-component formatter override - Math & interpolation: 30+ methods in
MathInfVal(Abs, Pow, Sqrt, Log, Clamp, RandomRange, …) and 10+ interpolation modes inInterpolateInfValincluding ease in/out and angle variants - Performant: explicit precision control,
in-parameter passing, andToString()caching keep real-time use efficient - Full sources: all scripts included with comments and summaries
Content
- Infinite value type: the
InfValstruct separated in multiple files - Formatter system:
IInfValFormatter,FormatterAsset, 4 built-in formatters - Support classes:
MathInfVal,InterpolateInfVal,InfValInputFieldUI component - Tests: NUnit test suite and custom randomized bulk tests
- Demo: a complete clicker-game demo with a save system, a scriptable-object database, and reusable UI scripts
Requirements
Unity 6.0 or later
Documentation
Get It
View on Unity Asset Store ($29.99) Play Demo
Patch Notes
v2.0.0 (June 1, 2026)
New Features:
- Formatter system: format and parse behavior is now driven by
IInfValFormatterimplementations, wrapped in aFormatterAsset(ScriptableObject). Assign aFormatterAssettoConfigurationorInfValInputFieldin the Inspector. Create one viaAssets > Create > Infinite Value > Formatter. Four built-in formatters are provided:ManualFormatter: fully explicit; configure unit list, separators, exponent marker, digit count, and display flags.ScientificFormatter: always formats as scientific notation (e.g.1.23e+6); configurable decimal separator, exponent marker, digit count, and trailing zeros.AlphabeticFormatter: idle-game style with letter suffixes (1.23a,4.56b, …,1.00aa); configurable alphabet, separators, digit count, and trailing zeros.CultureFormatter: derives separators from aCulture; uses native East Asian units (万/億...,만/억...,万/亿...) with 4-digit stepping forja-*,ko-*, andzh-*locales, and Western units (k/M/G...) for all others.
IInfValFormatter: implement this interface to create a fully custom formatter. RequiresFormat(in InfVal),TryParse(string, out InfVal), andIsValidPartialInput(string).InfValFormatHelper: static utility class for use when implementingIInfValFormatter. ProvidesFormat,TryParse,Parse,IsValidPartialInput,GetDecimalSeparator,GetGroupSeparator,AreUnitsValid, anddefaultExponentMarkers.InfValInputField.activeFormatter: read-only property returning the component’s assigned formatter, falling back toConfiguration.defaultFormatter.
Breaking Changes:
- Formatter system replaces format settings: all per-formatter options previously scattered across
ConfigurationandInfValInputFieldhave been removed. Assign aFormatterAssetto theDefault Formatterfield onConfiguration, or to theFormatterfield onInfValInputField. Fields removed:Configuration:maxDisplayedDigits,unitsList,displayOptions, and all decimal/separator/exponent/culture format settings.InfValInputField:useCustomUnits,unitsList,useCustomCulture,culture,useCustomMaxDisplayedDigits,maxDisplayedDigits,useCustomDisplayOptions,displayOptions.
InfVal.ToStringoverloads removed:ToString(int, string[], DisplayOption, ...)and all related overloads are gone. UseToString(IInfValFormatter)or the no-argToString()which usesConfiguration.defaultFormatter.- Parse API simplified:
Parse,TryParseoverloads takingstring[]orIFormatProviderare gone.ParseOrDefaultis fully removed. DisplayOptionenum removed.- Integer constructors: when no
precisionargument is provided, the resultingInfValnow has its precision set to the maximum digit count of the source type (e.g. 10 forint) instead of the actual digit count of the value. Pass an explicitprecisionto restore the old behavior. MathInfVal.Approximately: parameter renamed fromprecisiontosignificantDigits. Only affects code using named arguments.Configurationasset moved: from<Infinite Value package folder>/Resources/Configuration.assettoAssets/Resources/Infinite Value Configuration.asset. Re-apply your settings to the new asset, which is created automatically on the first domain reload after upgrading.operator ++andoperator --removed: usevalue + 1/value - 1instead.
Bug Fixes:
- Comparison operators (
<,>,<=,>=) andCompareTonow correctly order negative values of different magnitudes (e.g.-10 < -1previously returnedfalse). MathInfVal.MaxExponent,MinExponent,MaxPrecision, andMinPrecision(paramsoverloads): the accumulation loop read back.exponent/.precisionofInfValrepresentations of the loop indices instead of the original integers, producing incorrect results.MathInfVal.Approximately: did not account for the magnitude of the values; values with identical significant digits but different exponents (e.g.1.23e5vs.1.23e6) were incorrectly considered approximately equal.MathInfVal.RandomRange: now throwsArgumentExceptionifmin > max(previously silently swapped them); calling this repeatedly in the same frame no longer returns the same value every time.MathInfVal.RepeatandPingPong: now throwArgumentExceptioniflengthis zero (previously threwDivideByZeroException).InterpolateInfVal.InverseLinear: now throwsArgumentExceptionifmin == max(previously returnedNaNor infinity).
v1.2.1 (September 12, 2023)
- Fixed the Pow method, which could provide wrong results in some cases
- Greatly improved the precision of Pow and NthRoot methods when used with a negative second parameter
v1.2.0 (June 15, 2023)
Potentially breaking changes:
- Addition of assembly assets (runtime and editor)
- Explicit implementations for IConvertible and ISerializationCallbackReceiver interfaces
- Casting from string to InfVal is now explicit only
- Removal of the #define based configuration
Major:
- Fixed browser demo
- Optimized Log methods for both large and small values, resulting in improved performance across all cases
- Significantly enhanced Pow method performance in edge cases (up to 10,000 times faster!)
Minor:
- Modified folder hierarchy
- Improved existing comments and added summaries
- Unit test window: adjusted success color to match the pro skin, replaced nested classes with private classes
- Introduced MathBigInteger internal class
- Implemented various small optimizations
Other:
- Updated documentation and API to reflect the aforementioned changes
v1.1.0 (May 26, 2021)
This update makes the InfVal structure conserve precision instead of exponent, which is similar to what primitive value types do and simpler to use in most cases. Old usage can still be done using the ToExponent method. It makes the easiest way to use the structure also the most optimized way, allowing you to work with gigantic numbers.
- Constructors and casts now take a precision instead of an exponent as a second parameter. Also added a new constructor and cast taking an InfVal as a first parameter
- Arithmetic operations now conserve the highest precision instead of the lowest exponent
- The CalcType enum no longer exists. The Add, Sub, Mul and Div methods have been deleted because they are no longer required, and the Pow, Sqrt and NthRoot methods now take a bool argument instead of a CalcType
- The ToExp method is renamed to ToExponent; it now accepts an optional bool as a second argument that lets you edit the exponent without changing the digits
- Changing the exponent property has been optimized
- The inspector drawer now has a maximum count of digits displayed and can be used to call the ToPrecision method
- Updated the demo, unit tests window, documentation and API to reflect these changes
v1.0.0 - Initial release