ProblemBook.NET
  • ProblemBook.NET
  • LANGS
  • Задачник.NET
    • Math
      • «AugmentedAssignment» (Задача)
      • «Rounding1» (Задача)
      • «Overflow» (Решение)
      • «Overflow» (Задача)
      • «DivideByZero» (Решение)
      • «DivideByZero» (Задача)
      • «Eps» (Решение)
      • «DynamicIncrement» (Решение)
      • «Eps» (Задача)
      • «DynamicIncrement» (Задача)
      • «Rounding2» (Решение)
      • «AugmentedAssignment» (Решение)
      • «Rounding1» (Решение)
      • «Rounding2» (Задача)
    • Oop
      • «InheritanceNestedClass» (Задача)
      • «OverloadResolutionBasic» (Решение)
      • «OverloadResolutionOverride» (Решение)
      • «OverloadResolutionBasic» (Задача)
      • «OverloadResolutionOverride» (Задача)
      • «OverloadResolutionInheritance» (Решение)
      • «OverloadResolutionInheritance» (Задача)
      • «StaticFieldInGenericType» (Решение)
      • «StaticFieldInGenericType» (Задача)
      • «InheritanceNestedClass» (Решение)
    • ValueTypes
      • «Enumerator» (Решение)
      • «MutableProperty» (Задача)
      • «Enumerator» (Задача)
      • «StructLayout» (Решение)
      • «StructLayout» (Задача)
      • «Boxing» (Решение)
      • «Boxing» (Задача)
      • «MutableProperty» (Решение)
    • Strings
      • «InternmentAndMetadata» (Решение)
      • «CorruptedNumber» (Решение)
      • «InternmentAndMetadata» (Задача)
      • «TextElementEnumerator» (Решение)
      • «CorruptedNumber» (Задача)
      • «CaseInComparison» (Решение)
      • «TextElementEnumerator» (Задача)
      • «CaseInComparison» (Задача)
      • «StableSorting» (Решение)
      • «Secure» (Решение)
      • «CurrentCulture» (Решение)
      • «StableSorting» (Задача)
      • «Secure» (Задача)
      • «StringPlusNull» (Решение)
      • «CurrentCulture» (Задача)
      • «ExplicitlyInternment» (Решение)
      • «PlusChar» (Решение)
      • «StringPlusNull» (Задача)
      • «ExplicitlyInternment» (Задача)
      • «PlusChar» (Задача)
      • «NoStringInterning» (Решение)
      • «CorruptedString» (Решение)
      • «PlusString» (Решение)
      • «CompareToVsEquals» (Решение)
      • «NoStringInterning» (Задача)
      • «PlusString» (Задача)
      • «CorruptedString» (Задача)
      • «CompareToVsEquals» (Задача)
    • Linq
      • «QueryAfterRemove» (Решение)
      • «ClosureAndVariable» (Решение)
      • «QueryAfterRemove» (Задача)
      • «ClosureAndVariable» (Задача)
      • «EnumerableToArray» (Решение)
      • «QueryWithInc» (Решение)
      • «EnumerableToArray» (Задача)
      • «QueryWithInc» (Задача)
      • «LifeAfterYield» (Решение)
      • “YieldExceptionYield” (Решение)
      • «LifeAfterYield» (Задача)
      • «ExceptionYieldYield» (Решение)
      • «ClosureAndForeach» (Решение)
      • «TryYieldFinally» (Задача)
      • «ClosureAndFor» (Решение)
      • «ExceptionYieldYield» (Задача)
      • «YieldExceptionYield» (Решение)
      • «ClosureAndForeach» (Задача)
      • «ClosureAndFor» (Задача)
      • «YieldExceptionYield» (Задача)
    • Multithreading
      • «ThreadStaticVariable» (Решение)
      • «ThreadStaticVariable» (Задача)
      • «LockSlimInFinalizer» (Решение)
      • «LockSlimInFinalizer» (Задача)
    • Summary
    • Введение
  • ProblemBook.NET
    • Oop
      • “OverloadResolutionInheritance” (Solution)
      • “InheritanceNestedClass” (Solution)
      • “OverloadResolutionInheritance” (Problem)
      • “InheritanceNestedClass” (Problem)
      • “OverloadResolutionOverride” (Solution)
      • “OverloadResolutionOverride” (Problem)
      • “StaticFieldInGenericType” (Solution)
      • “OverloadResolutionBasic” (Solution)
      • “StaticFieldInGenericType” (Problem)
      • “OverloadResolutionBasic” (Problem)
    • Strings
      • “CorruptedNumber” (Problem)
      • “PlusString” (Solution)
      • “TextElementEnumerator” (Problem)
      • “PlusString” (Problem)
      • “StableSorting” (Solution)
      • “StableSorting” (Problem)
      • “CaseInComparison” (Solution)
      • “CaseInComparison” (Problem)
      • “NoStringInterning” (Solution)
      • “Secure” (Solution)
      • “CorruptedString” (Solution)
      • “CompareToVsEquals” (Solution)
      • “CurrentCulture” (Solution)
      • “NoStringInterning” (Problem)
      • “Secure” (Problem)
      • “CorruptedString” (Problem)
      • “CompareToVsEquals” (Problem)
      • “StringPlusNull” (Solution)
      • “CurrentCulture” (Problem)
      • “ExplicitlyInternment” (Solution)
      • “PlusChar” (Solution)
      • “InternmentAndMetadata” (Solution)
      • “CorruptedNumber” (Solution)
      • “StringPlusNull” (Problem)
      • “ExplicitlyInternment” (Problem)
      • “PlusChar” (Problem)
      • “InternmentAndMetadata” (Problem)
      • “TextElementEnumerator” (Solution)
    • Linq
      • “YieldExceptionYield” (Problem)
      • “QueryAfterRemove” (Problem)
      • “ClosureAndVariable” (Problem)
      • “QueryWithInc” (Solution)
      • “QueryWithInc” (Problem)
      • “LifeAfterYield” (Solution)
      • “LifeAfterYield” (Problem)
      • “EnumerableToArray” (Solution)
      • “EnumerableToArray” (Problem)
      • «YieldExceptionYield» (Solution)
      • “ExceptionYieldYield” (Solution)
      • “ClosureAndForeach” (Solution)
      • “TryYieldFinally” (Problem)
      • “ClosureAndFor” (Solution)
      • “ExceptionYieldYield” (Problem)
      • “YieldExceptionYield” (Solution)
      • “ClosureAndForeach” (Problem)
      • “ClosureAndVariable” (Solution)
      • “QueryAfterRemove” (Solution)
      • “ClosureAndFor” (Problem)
    • Multithreading
      • “ThreadStaticVariable” (Solution)
      • “LockSlimInFinalizer” (Solution)
      • “ThreadStaticVariable” (Problem)
      • “LockSlimInFinalizer” (Problem)
    • ValueTypes
      • “StructLayout” (Problem)
      • “MutableProperty” (Solution)
      • “Boxing” (Solution)
      • “MutableProperty” (Problem)
      • “Boxing” (Problem)
      • “Enumerator” (Solution)
      • “Enumerator” (Problem)
      • “StructLayout” (Solution)
    • 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
On this page
  • Answer
  • Explanation
  • Links

Was this helpful?

  1. ProblemBook.NET
  2. Math

“Rounding1” (Solution)

Previous“AugmentedAssignment” (Solution)Next“Rounding2” (Problem)

Last updated 6 years ago

Was this helpful?

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:

  • rounds to the nearest even integer (by default).

  • rounds down towards the negative infinity.

  • rounds up towards the positive infinity.

  • rounds down or up towards zero.

  • rounds towards the number away from zero.

Links

Math.Round
Math.Floor
Math.Ceiling
Math.Truncate
String.Format
Standard Numeric Format Strings
Custom Numeric Format Strings
Problem