Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • So the result is decimal or double that will never have anything after the point but there is not built in object to store the result as an "int" (without decimal places) that seems a bit lame?
    – Paul C
    Commented May 11, 2014 at 21:48
  • @CodeBlend: There isn't much call for designing frameworks around a desire to lose precision.
    – user1228
    Commented May 12, 2014 at 13:01
  • @CodeBlend: You would still lose precision because you are chopping off the decimal values of a number. Not sure what you're getting at.
    – user1228
    Commented May 12, 2014 at 15:02
  • Not sure this will work or not. Because Math.Truncate(-5.99999999999999999) returns -6.0 for me...!! Commented Oct 19, 2017 at 18:56
  • @Bharat Mori: It seems that -5.99999999999999999 is rounded to -6.0 before the truncate. Try with the suffix "m" and it'll work. Math.Truncate(-5.99999999999999999m) gives -5.
    – Henry
    Commented Feb 23, 2018 at 10:30