Gaussian/banker's rounding in JavaScript

后端 未结 6 1652
天涯浪人
天涯浪人 2020-11-27 02:51

I have been using Math.Round(myNumber, MidpointRounding.ToEven) in C# to do my server-side rounding, however, the user needs to know \'live\' what the result of

6条回答
  •  温柔的废话
    2020-11-27 03:39

    Stricly speaking, all of these implementations should handle the case of a negative number of digits to round to.

    It is an edge case, but still it would be wise to disallow it (or be very clear about what that means, for example -2 is rounding to the nearest amount of hundreds).

提交回复
热议问题