Storing fixed amounts

If you need to store or transmit a fixed value we recommend that you store the value as two discrete numbers:

  • minorUnits

  • scale

Both values should be stored as integers. If storing in a database minorUnits may need to be stored in a large int type.

Storing the value using this technique guarantees no precision loss when storing, transmitting or retrieving Fixed decimal values.

Last updated