# Máy tính làm tròn và chữ số có nghĩa

> Làm tròn số theo số chữ số thập phân, chữ số có nghĩa hoặc bội của mười hay một trăm gần nhất với chín quy tắc, gồm làm tròn về số chẵn khi ở giữa, làm tròn xuống và lên.

Phiên bản tương tác: https://www.calcopenly.com/vi/math/rounding-calculator
Chủ đề: Máy tính toán học

Rounding replaces a number with the nearest value that has a chosen number of decimal places or significant figures. The calculator finds the two candidates either side of the number at that precision and applies one of nine rules: the five “half” rules (up, to even, down, toward +∞, toward −∞) differ only when the number sits exactly halfway, while floor, ceiling, truncate and away-from-zero always move in one direction.

Lab reports round measurements to significant figures, prices are rounded to two decimal places, and programmers check which rule their language uses. The default, 1234.5678 to 2 decimal places, gives 1234.57, a change of +0.0022; the table lists the result under all nine rules at once. Negative decimal places round to tens (−1), hundreds (−2) and so on.

The rounded result keeps significant trailing zeros, so 999.96 to one place shows 1000.0, not 1000. Scientific notation shows exactly the significant figures kept, which removes the ambiguity of trailing zeros in a number like 1200.

## Dữ liệu đầu vào

- **Number**
- **Round to** (lựa chọn: Decimal places, Significant figures)
- **How many**: Negative decimal places round to tens (−1), hundreds (−2) and so on
- **Rounding rule** (lựa chọn: Half up (school rounding), Half to even (banker's), Half down, Half toward +∞, Half toward −∞, Floor (always down), Ceiling (always up), Truncate (toward zero), Away from zero)

## Kết quả

- Rounded — kết quả chính
- Without trailing zeros
- Rounding error (rounded − original)
- Ký hiệu khoa học
- Engineering notation

## Công thức

$$
\operatorname{round}_d(x) = \frac{\operatorname{rule}(x \cdot 10^{d})}{10^{d}}
$$

## Ví dụ có lời giải

### 1234.5678 to 2 decimal places

- Number: 1234.5678
- Round to: Decimal places
- How many: 2
- Rounding rule: Half up (school rounding)
- **Rounded: 1234.57**
- **Rounding error (rounded − original): 0.0022**
- Nguồn đối chiếu: Python Decimal('1234.5678').quantize(Decimal('0.01'), ROUND_HALF_UP)

### Banker's rounding of a tie, 2.345

- Number: 2.345
- Round to: Decimal places
- How many: 2
- Rounding rule: Half to even (banker's)
- **Rounded: 2.34**
- Nguồn đối chiếu: Python Decimal('2.345').quantize(Decimal('0.01'), ROUND_HALF_EVEN) = 2.34

### Same tie rounded half up

- Number: 2.345
- Round to: Decimal places
- How many: 2
- Rounding rule: Half up (school rounding)
- **Rounded: 2.35**
- Nguồn đối chiếu: Python Decimal quantize with ROUND_HALF_UP = 2.35

### 0.0012345 to 3 significant figures

- Number: 0.0012345
- Round to: Significant figures
- How many: 3
- Rounding rule: Half up (school rounding)
- **Rounded: 0.00123**
- **Ký hiệu khoa học: 1.23 × 10⁻³**
- Nguồn đối chiếu: Python Context(prec=3, rounding=ROUND_HALF_UP).plus(Decimal('0.0012345')) = 0.00123

### 1234.5 to 2 significant figures

- Number: 1234.5
- Round to: Significant figures
- How many: 2
- Rounding rule: Half up (school rounding)
- **Rounded: 1200**
- **Engineering notation: 1.2 × 10³**
- Nguồn đối chiếu: Python Context(prec=2).plus(Decimal('1234.5')) = 1.2E+3

### Floor of −2.5

- Number: -2.5
- Round to: Decimal places
- How many: 0
- Rounding rule: Floor (always down)
- **Rounded: −3**
- Nguồn đối chiếu: Python Decimal('-2.5').quantize(Decimal('1'), ROUND_FLOOR) = -3

## Câu hỏi

### How do you round to significant figures?

Count from the first non-zero digit, keep the number of digits you need, and round on the next one. For 0.0012345 to 3 significant figures, skip the leading zeros, keep 1, 2 and 3, and look at the 4: it is below 5, so the answer is 0.00123, or 1.23 × 10⁻³. Rounding 1234.5 to 2 significant figures gives 1200, where the two zeros only hold place value.

### What is banker's rounding?

Banker's rounding, or round half to even, sends an exact tie to whichever candidate ends in an even digit: 2.345 to two places becomes 2.34, and 2.355 becomes 2.36. Ties then go up and down equally often, so long sums do not drift upward. NIST SP 811 (B.7.1) gives this as its rule for discarding a 5 followed by zeros, and it is the default in IEEE 754 arithmetic and Python's round(), where round(2.5) is 2.

### Does 5 round up or down?

Under school rounding (half up) an exact 5 rounds up, away from zero: 2.345 to two places is 2.35, and −2.5 to a whole number is −3. Under banker's rounding the same ties go to the even digit, giving 2.34 and −2. The rule matters only for exact ties; 2.3451 becomes 2.35 under both because it lies above halfway.

### What is the difference between floor, ceiling and truncate?

Floor always moves down toward −∞, ceiling always up toward +∞, and truncation drops the extra digits, which moves toward zero. Floor and truncate agree for positive numbers but split for negatives: −2.5 to a whole number floors to −3, truncates to −2, and has a ceiling of −2. None of them looks at which candidate is nearer, so 1.99 floors to 1.

### How do you round to the nearest ten, hundred or thousand?

Enter negative decimal places: −1 rounds to tens, −2 to hundreds and −3 to thousands. 1234.5678 to −2 places is 1200 under every half rule. 1250 sits exactly halfway between 1200 and 1300, so it becomes 1300 under half up but 1200 under banker's rounding, because 2 is the even digit.

### “Máy tính làm tròn và chữ số có nghĩa” chính xác đến mức nào?

Độ chính xác phụ thuộc vào dữ liệu nhập và giả định của phương pháp. Phép tính thập phân dùng 50 chữ số có nghĩa, nhưng ước lượng, phương pháp số và dữ liệu nguồn có thể kém chính xác hơn; làm tròn khi hiển thị không loại bỏ các giới hạn đó. Ví dụ có lời giải đã đối chiếu với nguồn độc lập: 8. Ví dụ, “1234.5678 to 2 decimal places” được kiểm tra bằng Python Decimal('1234.5678').quantize(Decimal('0.01'), ROUND_HALF_UP).

### Phương pháp này lấy từ đâu?

IEEE 754-2019 — rounding-direction attributes (roundTiesToEven, roundTiesToAway, toward ±∞, toward 0); NIST SP 811, Appendix B.7 — rounding numerical values; Python decimal module — rounding modes.

## Nguồn

- [IEEE 754-2019 — rounding-direction attributes (roundTiesToEven, roundTiesToAway, toward ±∞, toward 0)](https://standards.ieee.org/ieee/754/6210/)
- [NIST SP 811, Appendix B.7 — rounding numerical values](https://www.nist.gov/pml/special-publication-811)
- [Python decimal module — rounding modes](https://docs.python.org/3/library/decimal.html#rounding-modes)
