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