C# Math.Round double .5 -
i have try math.round
class. let see
math.round(2.5) //2.0 math.round(-2.5) //-2.0 math.round(2.5,midpointrounding.toeven) // 2.0 math.round(2.5,midpointrounding.awayfromzero) //3.0
my simple question if change number -77777777.5 why result -77777778.0 not -77777777.0
math.round(-77777777.5) // -77777778.0 math.round(-77777777.5,midpointrounding.awayfromzero) // -77777778.0 math.round(-77777777.5,midpointrounding.toeven) // -77777778.0
thanks idea , suggestion.
the default midpointrounding
mode toeven
. in mode, explained documentation (where a
input value),
the integer nearest a. if fractional component of halfway between 2 integers, 1 of , other odd, number returned.
-77777777.5
has 2 nearest integers -77777777
, -77777778
latter 1 1 returned.
in awayfromzero
mode, -77777778
further 0 -77777777
.
Comments
Post a Comment