I have been using a library called Large Numbers, it allows me to store and use big numbers that are needed in a game like Project Hack. It also has great formatters for displaying numbers with billions, trillion, quadrillion, and more. Not to forget scientific notation if desired.
However, it uses doubles which is fine for most scenarios except one crucial one in this game.
You cannot have 1.3 hackers. You see the problem!
The problem starts with coeficients and magnitudes. That is how the library works. And you cannot simply floor the coeficient with the result you would expect after the magnitude starts to grow.
After many days trying to fix this issue and with the help of friends on the live stream I decided to go a different way.
Big Ints allows for extremely large numbers and uses integers as the name suggests.
This leaves me with two problems to solve.
- I now need to format the numbers for display just like before.
I’m not going to make me sound clever here, I simply used Claude Code to figure out a formatting library for me. It two two minutes and the work was done. So a better use of my time and less chance of me screwing it up.
Plus I now have a number formatter for any project built with standard C# going forward.
- I still need double values for things like Hacker Power and Dark Web Coins.
This one was a little more work but I got there. Essentially I format the numbers into a value that gives me the fractional values for the digit count I provide it. For example .0000 and it does the number crunching returning the value.
This post probably makes it sound simple and short, but in reality I have been trying to resolve this problem for a few weeks on and off. So I’m relieved to finally get a solution that appears to work in a predictable way and I can move on from the last major annoying bug that needed fixing before the next build for some testers to play with.