EMC Storage (in memory) - Skirlez/fabricated-exchange GitHub Wiki
This page will discuss how EMC is stored in the mod.
Infinite precision
Every EMC value in Fabricated Exchange is stored as two BigIntegers which are treated as a numerator and denominator representing the value. BigInteger is a Java class that can represent an integer of arbitrary size, and with two of them, you can represent any real number that isn't irrational with enough RAM. The reason I chose to do this is to solve two problems that every previous iterations of the mod had:
- EMC was bound with some limit, either (2^32)/2 or (2^64)/2.
- Items like Stone slab could not have EMC, as it was below 1.
Doing it like this fixes both.
Performance Concerns
I have yet to run into performance issues due to the added overhead of the new number class. If they arise, there are potential solutions, such as switching to a faster alternative to BigInteger, or possibly switching to long which would unfix problem 1, but would likely increase performance by a lot.