Quantity

    Quantity is a fixed-point representation of a number. It provides convenient marshaling/unmarshaling in JSON and YAML, in addition to String() and AsInt64() accessors.

    The serialization format is:

    When a Quantity is parsed from a string, it will remember the type of suffix it had, and will use the same type again when it is serialized.

    Before serializing, Quantity will be put in “canonical form”. This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:

    The sign will be omitted unless the number is negative.

    Note that the quantity will NEVER be internally represented by a floating point number. That is the whole point of this exercise.

    Non-canonical values will still parse as long as they are well formed, but will be re-emitted in their canonical form. (So always use canonical form, or don’t diff.)

    This format is intended to make it difficult to use these numbers without writing some sort of special handling code in the hopes that that will cause implementors to also use a fixed point implementation.


    ```