/fast-bigdouble

GC Friendly, Fastest Big Double for IdleGame.

Primary LanguageC#MIT LicenseMIT

Fast-BigDouble

This source code is a fork of BreakInfinity that has been modified for idle games that use very large numbers.

  • GC Friendly
  • Fast Double Parse

Why Fast?

The functions see in the picture were called 1000 times in one frame

image

While double.Parse and double.ToString are great for their versatility, they are very slow in special situations.

In games that use large numbers, such as idle games, you don't need to care as much about the accuracy of floating-point numbers, so it's a performance advantage to create your own algorithm to parse double.

And Unless it's a case like ToString, which requires a string to be created anew, it will behave as memory efficient code with near zero GC

How to Use?

It is exactly the same as BigInfinity.cs, but it must follow these rules

Simple.

BigDouble _ = new BigDouble("1000"); // Number Constructor
BigDouble _ = new BigDouble("1.0A"); // Alphabet Constructor
BigDouble _ = new BigDouble("999.9A"); // Alphabet Constructor
BigDouble _ = new BigDouble("1000A"); // Alphabet Constructur, But It's Throw Error. Alphabet Number Allow -999.9~999.9 for performance.
BigDouble _ = new BigDouble("9.999e100"); // Exponent Constructor. It's Very Fast!!!!
BigDouble _ = new BigDouble("100e100"); // Exponent Constructor.
new BigDouble(1e3).ToString() // Result = "1.0A"