1
I have a code that rounds up a value like decimal
for homes I want, and would like to implement it on Android in Java however I’m having some difficulties, follows below the code in C#.
public static class Valor
{
public static decimal Arredondar(decimal valor, int casasDecimais)
{
var valorNovo = decimal.Round(valor, casasDecimais);
var valorNovoStr = valorNovo.ToString("F" + casasDecimais, CultureInfo.CurrentCulture);
return decimal.Parse(valorNovoStr);
}
public static decimal? Arredondar(decimal? valor, int casasDecimais)
{
if (valor == null) return null;
return Arredondar(valor.Value, casasDecimais);
}
}
From what I researched I would have to use Bigdecimal
but I’m having several problems.
We can help if you tell us what the problems are. You don’t seem to have problems, although I don’t know if you need all this. I don’t know what the objective is. Doesn’t seem to need
BigDecimal
.– Maniero