Rounding numbers to the nearest tenth

User ForumRounding numbers to the nearest tenth
yyusof asked 3 years ago

instead of round to the nearest integer, how to round up to 2 decimal point.

for example:

0.1789234 = 0.20

1 Answers
aptech Staff answered 3 years ago

Multiply the number by 10, round the number and then divide by 10.

round_x = round(10 * x)/10;