Math.Floor()和Math.Truncate之间差() [英] Difference between Math.Floor() and Math.Truncate()
问题描述
()之间 Math.Floor的区别是什么
和<一href="http://msdn.microsoft.com/en-us/library/system.math.truncate.aspx"><$c$c>Math.Truncate()$c$c>在.NET?
What is the difference between Math.Floor()
and Math.Truncate()
in .NET?
推荐答案
Math.Floor
几轮下来, Math.Ceiling
向上舍,和 Math.Truncate
将向零舍入。因此, Math.Truncate
就像 Math.Floor
为正数,而像数学。天花板
为负数。这里的参考。
Math.Floor
rounds down, Math.Ceiling
rounds up, and Math.Truncate
rounds towards zero. Thus, Math.Truncate
is like Math.Floor
for positive numbers, and like Math.Ceiling
for negative numbers. Here's the reference.
有关完整性, Math.Round
四舍五入为最接近的整数。如果数量是两个整数之间恰好中途,则舍朝向连一个。 参考。
For completeness, Math.Round
rounds to the nearest integer. If the number is exactly midway between two integers, then it rounds towards the even one. Reference.
另请参见:<一href="http://stackoverflow.com/questions/14/whats-the-difference-between-math-floor-and-math-truncate-in-c/580252#580252">Pax暗黑破坏神的回答。强烈推荐!
See also: Pax Diablo's answer. Highly recommended!
这篇关于Math.Floor()和Math.Truncate之间差()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!