# “Rounding1” (Solution)

## Answer

```
| Number | Round | Floor | Ceiling | Truncate | Format |
|   -2.9 |    -3 |    -3 |      -2 |       -2 |     -3 |
|   -0.5 |     0 |    -1 |       0 |        0 |     -1 |
|    0.3 |     0 |     0 |       1 |        0 |      0 |
|    1.5 |     2 |     1 |       2 |        1 |      2 |
|    2.5 |     2 |     2 |       3 |        2 |      3 |
|    2.9 |     3 |     2 |       3 |        2 |      3 |
```

## Explanation

If the number is exactly halfway between two possibilities, the following rules will work:

* [Math.Round](http://msdn.microsoft.com/library/system.math.round.aspx) rounds to the nearest even integer (by default).
* [Math.Floor](http://msdn.microsoft.com/library/system.math.floor.aspx) rounds down towards the negative infinity.
* [Math.Ceiling](http://msdn.microsoft.com/library/system.math.ceiling.aspx) rounds up towards the positive infinity.
* [Math.Truncate](http://msdn.microsoft.com/library/system.math.truncate.aspx) rounds down or up towards zero.
* [String.Format](http://msdn.microsoft.com/library/system.string.format.aspx) rounds towards the number away from zero.

## Links

* [Standard Numeric Format Strings](http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx)
* [Custom Numeric Format Strings](http://msdn.microsoft.com/en-us/library/0c899ak8.aspx)

[Problem](https://andreyakinshin.gitbook.io/problembookdotnet/en/math/rounding1-p)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://andreyakinshin.gitbook.io/problembookdotnet/en/math/rounding1-s.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
