js
Math.round(number)مع السالب التقريب لفوق معناه ناحية الصفر: Math.round(-2.5) بتدّي -2. للتقريب لعدد خانات عشرية استخدم toFixed أو اضرب واقسم.
البرهان
js
console.log(Math.round(2.4), Math.round(2.5), Math.round(2.6));
console.log(Math.round(-2.5));
console.log('لخانتين:', Math.round(1.2345 * 100) / 100);
console.log(Math.round(2.4999999));النتيجة
2 3 3 -2 لخانتين: 1.23 2