1h Better money round
This commit is contained in:
parent
aa771c0cbb
commit
5428fa3722
@ -27,7 +27,7 @@ public abstract class MoneyMixinAbstract implements MoneyMixin
|
||||
if (fractionalDigits < 0) return amount;
|
||||
|
||||
// 0 means no fractional digits
|
||||
if (fractionalDigits == 0) return Math.ceil(amount);
|
||||
if (fractionalDigits == 0) return moneyCeil(amount);
|
||||
|
||||
// OK! I'll have to calculate :P
|
||||
int factor = (int) Math.round(Math.pow(10, fractionalDigits));
|
||||
@ -38,6 +38,12 @@ public abstract class MoneyMixinAbstract implements MoneyMixin
|
||||
return amount;
|
||||
}
|
||||
|
||||
public static double moneyCeil(double amount)
|
||||
{
|
||||
if (amount < 0) return Math.floor(amount);
|
||||
else return Math.ceil(amount);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// MOVE
|
||||
// -------------------------------------------- //
|
||||
|
@ -71,13 +71,14 @@ public class MoneyMixinVault extends MoneyMixinAbstract
|
||||
else
|
||||
{
|
||||
int fractionalDigits = this.fractionalDigits();
|
||||
amount = prepare(amount);
|
||||
if (fractionalDigits < 0)
|
||||
{
|
||||
return String.valueOf(amount);
|
||||
}
|
||||
else if (fractionalDigits == 0)
|
||||
{
|
||||
return String.valueOf((int)Math.round(amount));
|
||||
return String.valueOf((int)amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user