WIP: Start numeric type for resources

Opening for comments on this approach. Not functional yet.
As per the conversation, for anyone who is listening:

I think we should start with the simplest things we can make that works.
 Be flexible in what you accept, but only emit fundamental units.  I think
this will be far simpler to understand and implement.  THEN, once that is
committed, we can evaluate the utility of pretty-formatting output.

Put another way - there are 800 things you could be doing, is
pretty-formatting really that important?

Tim


On Fri, Sep 5, 2014 at 2:15 PM, Daniel Smith <notifications@github.com>
wrote:

> In pkg/util/numeric.go:
>
> > +
> > +// Numeric is a fixed-point representation of a number.
> > +// It provides convenient marshaling/unmarshaling in JSON and YAML,
> > +// in addition to String() and Int64() accessors.
> > +// The serialization format is:
> > +//
> > +// <serialized>      ::= <sign><numeric> | <numeric>
> > +// <numeric>         ::= <digits><exponent> | <digits>.<digits><exponent>
> > +// <sign>            ::= "+" | "-"
> > +// <digits>          ::= 0 | 1 | ... | 9
> > +// <exponent>        ::= <binaryExponent> | <decimalExponent>
> > +// <decimalExponent> ::= "e" <digits>
> > +//   (Where digits is always a multiple of 3)
> > +// <binaryExponent>  ::= mi | i | Ki | Mi | Gi | Ti | Pi | Xi
> > +//
> > +// Before serializing, Numeric will be put in "canonical form".
>
> (We just chatted in person but I had this written up already so still
> sending it.)
>
> When I say "canonical" here, that's for its serialized form, i.e., when
> written to disk/JSON/what have you. Clearly, when stored in memory, it
> should be the way you say.
>
> I'm considering just making separate types for this for the "X * 2 ^
> (Y*10)" vs "X * 10 ^ (Y * 3)" cases.
>
> Also consider that, even as written, if someone writes 1.5Gi and then for
> some reason switches to the 10^3x form, you would see 1610612736, *not*
> 1.611e9. (Also the canonical form is 1500Mi, not 1.5Gi)
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/kubernetes/pull/1185/files#r17198771>
> .
>