File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 1- using System . Globalization ;
1+ using System ;
2+ using System . Globalization ;
23
34namespace DFe . Classes
45{
56 public static class Valor
67 {
78 public static decimal Arredondar ( this decimal valor , int casasDecimais )
89 {
9- var valorNovo = decimal . Round ( valor , casasDecimais ) ;
10- var valorNovoStr = valorNovo . ToString ( "F" + casasDecimais , CultureInfo . CurrentCulture ) ;
11- return decimal . Parse ( valorNovoStr ) ;
10+ var valorArredondado = decimal . Round ( valor , casasDecimais , MidpointRounding . ToEven ) ;
11+ var valorArredondadoFormatado = valorArredondado . ToString ( "F" + casasDecimais , CultureInfo . CurrentCulture ) ;
12+ return decimal . Parse ( valorArredondadoFormatado ) ;
1213 }
1314
1415 public static decimal ? Arredondar ( this decimal ? valor , int casasDecimais )
Original file line number Diff line number Diff line change @@ -7,9 +7,9 @@ public static class Valor
77 {
88 public static decimal Arredondar ( this decimal valor , int casasDecimais )
99 {
10- var valorNovo = decimal . Round ( valor , casasDecimais , MidpointRounding . AwayFromZero ) ;
11- var valorNovoStr = valorNovo . ToString ( "F" + casasDecimais , CultureInfo . CurrentCulture ) ;
12- return decimal . Parse ( valorNovoStr ) ;
10+ var valorArredondado = decimal . Round ( valor , casasDecimais , MidpointRounding . ToEven ) ;
11+ var valorArredondadoFormatado = valorArredondado . ToString ( "F" + casasDecimais , CultureInfo . CurrentCulture ) ;
12+ return decimal . Parse ( valorArredondadoFormatado ) ;
1313 }
1414
1515 public static decimal ? Arredondar ( this decimal ? valor , int casasDecimais )
You can’t perform that action at this time.
0 commit comments