Duke's Big Numbers 1.0
C++ and Blueprint libraries for performing math, analysis, and formatting with really large numbers (>10e308).
Loading...
Searching...
No Matches
Duke's Big Numbers (DBN)

Duke's Big Numbers Logo

In case of corrections and errata, the most up-to-date on-line version of the documentation for this release of DBN is available at https://smilingcatentertainment.com/api/docs/DukesBigNumbers/1.0.

In case of new releases, the most up-to-date on-line version of the documentation for the most current release of DBN is available at https://smilingcatentertainment.com/api/docs/DukesBigNumbers/current.

Introduction

Duke's Big Numbers (DBN) is a C++ code plugin for Unreal Engine (UE) with Blueprint support that enables calculation, storage, and formatting of VERY LARGE integer numbers with full precision.

The Problem Statement

The need for very large integer numbers.

Games increasingly require calculations using very large and precise integers. This is especially true of incremental games, where numbers can range well beyond 101,000. This type of game needs to not only be able to handle numbers very large in scale, but also have calculations that lose no integral precision at those very large scales.

Operation on numbers of this scale also needs to be as fast as possible, leaving as much frame time as possible for other game concerns.

Math on numbers of this scale also needs to be allocation-friendly, so that memory management artifacts such as garbage collection do not adversely affect performance.

Standard integral types are not up to the task

Standard unsigned integral types in UE top out at around 18.4 quintillion (1.84e19) for uint64. Only signed integral types are available to Blueprints, further reducing the numerical range available to Blueprints to about 9.2 quintillion (9.2e18) for Integer64.

Floating point types are not up to the task

Floating point types allow calculation beyond the bounds of standard integral types, but quickly lose precision. Single-precision floating point values go up to 3.4e38, but begin losing integral precision at around 16.8 million (1.68e7). Double-precision floating point values go up to 1.8e308, but begin losing integral precision at around 9.0 quadrillion (9.0e15).

Multiple-precision integer math is needed

What is needed is a data type and library that can store multiple-precision integers and perform efficient calculations on them.

DBN as the solution

DBN is presented as a solution to the challenges of calculating, storing, and formatting very large integers.

DBN allows storage of full-precision integers of arbitrary scale. See {BigIntegerLimits} below.

DBN is focused on performance and continual performance improvement. All core functionality is implemented in C++. Over the course of future development, measured changes will be made in order to ensure that the best possible game performance can be achieved.

DBN allows large integers to be treated as a quasi-immutable type for cognitive convenience. However, when every allocation matters, operations have versions exposed that will mutate rather than copy values, if possible.

DBN offers a wide range of calculation functions, with more slated to be added with each release.

DBN has a plethora of formatting options tailored to games that can be customized to individual project needs.

In summary, DBN is a full solution to the need for very large integers in games made using UE.

Limits (Suggested and Absolute):

The minimum amount of memory used by a FBigInteger increases by 4 bytes every time the scale of the number increases by 2^32. Naturally, it follows that the larger the number, the higher the memory and performace cost of working with the number, until that cost becomes intolerable.

  • For a couple of O(n) complexity operations per frame (such as adds), practical limit is around 233,554,432, or around 1010,000,000.
  • For a couple of O(n2) complexity operations per frame (such as multiplies of numbers of similar length), practical limit is around 216,384, or around 104,900.
  • Balance from there. If you want 10x more operations per frame, use limits 1/10th the size given for O(n) operations and roughly 1/3 the size given for O(n2) operations.
  • Absolute limit is 234,359,738,367-1, or roughly 1010,356,025,143, though numbers of this scale occupy 8GB apiece and take many seconds to operate on, if enough contiguous blocks of memory that large can even be found!
Note
Exact limits will depend on MANY factors and can change over the life of your project as it grows in complexity. Be sure to test early and often using your desired maximum limits.