// Proto serialization for decimal numbers.
// This is based on representing numbers from mpdecimal (IEEE 754).

// TODO(blais): Change this to proto3 when it becomes possible to either (a)
// enable --experimental_allow_proto3_optional by providing flags to the native
// proto_library() rule (currently not possible AFAICT), or (b) it is supported
// directly, and metadata can be used to enable it. In the meantime we use
// proto2, because I really do want optionals with a presence field.
syntax = "proto2";

package beancount;

// Variant for number representation.
message Number {
  // Exact string for the number, explicit and readable, requires conversion.
  optional string exact = 1;

  // Decomposed representation; harder to read for humans, directly instantiable
  // for computers.
  optional MpDecimal mpd = 2;
}

// Decomposed representation of mpd_t. See mpdecimal for details.
message MpDecimal {
  optional int32 flags = 1;
  optional int64 exp = 2;
  optional int64 digits = 3;
  optional int64 len = 4;
  repeated uint64 data = 6;
}
