Skip to main content

[JSR-354] Re: Mathematical Operations on MonetaryAmount

  • From: Chris Pheby <chris@...>
  • To: "jcurrency_mail@..." <jcurrency_mail@...>
  • Subject: [JSR-354] Re: Mathematical Operations on MonetaryAmount
  • Date: Sat, 13 Jul 2013 14:34:53 +0000
  • Accept-language: en-GB, en-US

My question was:

GBP5 *  5  = GBP 25 is clear enough

But not sure about

GBP 5 * GBP 5
or even
GBP 5 * USD 5

In what situation would you perform these multiplications?

Similarly

EUR 5 + EUR 5 seems clear
But
EUR5 + 5 is less clear

Regards Chris

From: Werner Keil [mailto:werner.keil@...]
Sent: 13 July 2013 22:29
To: jcurrency_mail@...
Subject: [JSR-354] Re: Mathematical Operations on MonetaryAmount

I remember the latter method was to add a numeric amount of the same 
currency. We do have a restriction or guidance, that the currencies of both 
arguments should be the same, otherwise one would never know, which exchange 
rate to explicitely use and where to take it 
from[cid:image001.gif@01CE8019.2D6BF2B0]

So I'd say it makes sense in both cases. For multiplication it certainly does 
even more, are we missing a numeric only argument there?

Regards,
Werner
On Sat, Jul 13, 2013 at 4:15 PM, Chris Pheby <chris@...<mailto:chris@...>> 
wrote:
On MonetaryAmount, most of the mathematical operations are overloaded for 
both MonetaryAmount and Number as parameters. I am not sure this should be 
the case.

For example, add and subtract:

    public Money add(MonetaryAmount amount);
    public Money add(Number amount);

Adding two MonetaryAccounts makes perfect sense, but adding a number to a 
monetary amt - less clear. Why not just convert the number to a 
MonetaryAmount explicitly.

For the multiply, divide... and remainder methods, the opposite may be true. 
In this case, it is unclear what the meaning of using a MonetaryAmount as an 
operand is.

Regards Chris




GIF image



[JSR-354] Mathematical Operations on MonetaryAmount

Chris Pheby 07/13/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

Werner Keil 07/13/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

Chris Pheby 07/13/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

Werner Keil 07/13/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

tom.huesler@... 07/13/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

Werner Keil 07/14/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

Chris Pheby 07/14/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

Stephen Colebourne 07/14/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

Werner Keil 07/14/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

Werner Keil 07/14/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

Werner Keil 07/16/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

Sascha Freitag 07/28/2013

[JSR-354] Re: Mathematical Operations on MonetaryAmount

Werner Keil 07/28/2013
 
 
Close
loading
Please Confirm
Close