Last active
November 8, 2015 23:21
-
-
Save loctanvo/5b7b61c9fdd5e78443a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
namespace MathRound.Demo | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
Console.WriteLine("Math.Round(x, MidpointRounding.AwayFromZero)"); | |
Console.WriteLine(Round(1.5)); | |
Console.WriteLine(Round(2.5)); | |
Console.WriteLine(Round(3.5)); | |
} | |
private static string Round(double value) | |
{ | |
var result = Math.Round(value, MidpointRounding.AwayFromZero); | |
return string.Format(CultureInfo.InvariantCulture, "Math.Round({0}) --> {1}", value, result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment