@@ -364,7 +364,8 @@ public FastMoney multiply(Number multiplicand) {
364364 if (isOne (multiplicand )) {
365365 return this ;
366366 }
367- return new FastMoney (Math .round (this .number * multiplicand .doubleValue ()), getCurrency ());
367+ return new FastMoney (Math .multiplyExact (this .number , getInternalNumber (multiplicand , false )),
368+ getCurrency ());
368369 }
369370
370371 /*
@@ -373,7 +374,7 @@ public FastMoney multiply(Number multiplicand) {
373374 */
374375 @ Override
375376 public FastMoney negate () {
376- return new FastMoney (this .number * - 1 , getCurrency ());
377+ return new FastMoney (Math . multiplyExact ( this .number , - 1 ) , getCurrency ());
377378 }
378379
379380 /*
@@ -385,7 +386,7 @@ public FastMoney plus() {
385386 if (this .number >= 0 ) {
386387 return this ;
387388 }
388- return new FastMoney (this .number * - 1 , getCurrency ());
389+ return new FastMoney (Math . multiplyExact ( this .number , - 1 ) , getCurrency ());
389390 }
390391
391392 /*
@@ -398,8 +399,8 @@ public FastMoney subtract(MonetaryAmount subtrahend) {
398399 if (subtrahend .isZero ()) {
399400 return this ;
400401 }
401- long subtrahendAsLong = getInternalNumber (subtrahend .getNumber (), false );
402- return new FastMoney ( Math . addExact ( this . number , - 1L * subtrahendAsLong ), getCurrency ());
402+ return new FastMoney ( Math . subtractExact ( this . number , getInternalNumber (subtrahend .getNumber (), false )),
403+ getCurrency ());
403404 }
404405
405406 /*
@@ -412,7 +413,7 @@ public FastMoney remainder(Number divisor) {
412413 if (isOne (divisor )) {
413414 return new FastMoney (0 , getCurrency ());
414415 }
415- return new FastMoney (this .number % getInternalNumber (divisor , true ), getCurrency ());
416+ return new FastMoney (this .number % getInternalNumber (divisor , false ), getCurrency ());
416417 }
417418
418419 private boolean isOne (Number number ) {
0 commit comments