Difference between Math.Floor() and Math.Truncate().
Round(1.5) = 2
Round(2.5) = 2
Round(1.5, MidpointRounding.AwayFromZero) = 2
Round(2.5, MidpointRounding.AwayFromZero) = 3
Round(1.55, 1) = 1.6
Round(1.65, 1) = 1.6
Round(1.55, 1, MidpointRounding.AwayFromZero) = 1.6
Round(1.65, 1, MidpointRounding.AwayFromZero) = 1.7
Truncate(2.10) = 2
Truncate(2.00) = 2
Truncate(1.90) = 1
Truncate(1.80) = 1
Source: By Anonymous User as answer to the question
This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 3.0
Related code-snippets:
- How do you calculate someone's age based on datetime?
- Anatomy of a memory leak -'memory leak'
- Do you like compression of files? How do you decompress them?
- How can I sync my SVN revision number with my ASP.NET web site?
- What is the catch all algorithm?
- How do you sort a dictionary by value?
- If a.net Embedded Database runs on a network. Embedded Database can run off a network.
- How can I create an object instance from a Type?
- Localising Date format descriptors: A set of localised descriptors for localising the date format in an existing format.
- I want to solve a linear equation. How can I do that?
- A little diversion into floating point (im)precision, part 1 | 1 – 0 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 1 | 2 | 1 | 2 | 1 | 1 | 2 | 1 | 2 | 3 | 4 | A little diversion into floating point (im)precision, part 1 | 3 | 4 | 5 | 5 | 8 | 8 | 2 | 3 | 4 | 7 | 8 | 7 | 7 | 7 | 6 | 1 | 1 | 5 | 1
- How should I limit the size of the QueueT> in.NET?
- How do you check for file locks?
- How can I map a latitude/longitude on a distorted map?
- Can multiple dataContext classes be a good use of data?