P
P
ProblemBook.NET
Search…
P
P
ProblemBook.NET
ProblemBook.NET
LANGS
Задачник.NET
ProblemBook.NET
Oop
Strings
Linq
Multithreading
ValueTypes
Math
“Rounding2” (Solution)
“AugmentedAssignment” (Solution)
“Rounding1” (Solution)
“Rounding2” (Problem)
“Rounding1” (Problem)
“AugmentedAssignment” (Problem)
“DivideByZero” (Solution)
“DivideByZero” (Problem)
“DynamicIncrement” (Solution)
“DynamicIncrement” (Problem)
“Eps” (Solution)
“Eps” (Problem)
“Overflow” (Solution)
“Overflow” (Problem)
Summary
Introduction
Attribution-NonCommercial-NoDerivatives 4.0 International
Powered By
GitBook
“Rounding1” (Solution)
Answer
1
| Number | Round | Floor | Ceiling | Truncate | Format |
2
| -2.9 | -3 | -3 | -2 | -2 | -3 |
3
| -0.5 | 0 | -1 | 0 | 0 | -1 |
4
| 0.3 | 0 | 0 | 1 | 0 | 0 |
5
| 1.5 | 2 | 1 | 2 | 1 | 2 |
6
| 2.5 | 2 | 2 | 3 | 2 | 3 |
7
| 2.9 | 3 | 2 | 3 | 2 | 3 |
Copied!
Explanation
If the number is exactly halfway between two possibilities, the following rules will work:
Math.Round
rounds to the nearest even integer (by default).
Math.Floor
rounds down towards the negative infinity.
Math.Ceiling
rounds up towards the positive infinity.
Math.Truncate
rounds down or up towards zero.
String.Format
rounds towards the number away from zero.
Links
Standard Numeric Format Strings
Custom Numeric Format Strings
Problem
Previous
“AugmentedAssignment” (Solution)
Next
“Rounding2” (Problem)
Last modified
3yr ago
Copy link
Contents
Answer
Explanation
Links