Open stevecondylios opened 3 years ago
round2 = function(x, decimal_places = 0) { posneg = sign(x) z = abs(x)*10^decimal_places z = z + 0.5 + sqrt(.Machine$double.eps) z = trunc(z) z = z/10^decimal_places z*posneg }
Examples:
round2(3.5) [1] 4 round2(2.5) [1] 3 round2(0.15, decimal_places = 1) [1] 0.2
Consider roundc() (or other name) so that:
roundc()
Examples:
Consider
roundc()
(or other name) so that: