Fiat, Monetary and ExchangeRate

Introduce Fiat as a holder for fiat values. Coin and Fiat share an interface Monetary so that monetary infrastructure can be re-used.

Adapt CoinFormat to be used with Monetary. Add an ExchangeRate value class that can convert from Coin to Fiat and back.

Hmmm……..Are you calculating the units of beer I drink every week again :)

On 16 Aug 2014, at 14:00, Mike Hearn <notifications@github.com> wrote:

> In core/src/main/java/com/google/bitcoin/utils/ExchangeRate.java:
> 
> > +
> > +    public final Coin coin;
> > +    public final Fiat fiat;
> > +
> > +    public ExchangeRate(Coin coin, Fiat fiat) {
> > +        this.coin = coin;
> > +        this.fiat = fiat;
> > +    }
> > +
> > +    public ExchangeRate(Fiat fiat) {
> > +        this.coin = Coin.COIN;
> > +        this.fiat = fiat;
> > +    }
> > +
> > +    public Fiat coinToFiat(Coin convertCoin) {
> > +        final BigInteger converted = BigInteger.valueOf(convertCoin.value).multiply(BigInteger.valueOf(fiat.value))
> Overflows too easily? You mean because long isn't large enough? That's surprising. 63 bits is very large. What kind of calculations are you doing that overflow?
> 
> —
> Reply to this email directly or view it on GitHub.
>