Timeline for Best way to get whole number part of a Decimal number
Current License: CC BY-SA 3.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 8, 2020 at 11:57 | comment | added | Paul C | @Simon this was 10 years ago :) ... wow a whole decade since I wrote that comment, blimey | |
Nov 30, 2020 at 19:25 | comment | added | Simon Sultana | @Coops: try (int)Math.Truncate(number) | |
Feb 23, 2018 at 10:30 | comment | added | Henry | @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. | |
Oct 19, 2017 at 18:56 | comment | added | Bharat Mori | Not sure this will work or not. Because Math.Truncate(-5.99999999999999999) returns -6.0 for me...!! | |
May 12, 2014 at 15:02 | comment | added | user1228 | @CodeBlend: You would still lose precision because you are chopping off the decimal values of a number. Not sure what you're getting at. | |
May 12, 2014 at 13:01 | comment | added | user1228 | @CodeBlend: There isn't much call for designing frameworks around a desire to lose precision. | |
May 11, 2014 at 21:48 | comment | added | Paul C | 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? | |
Jul 21, 2011 at 12:26 | history | edited | user1228 | CC BY-SA 3.0 |
deleted 2426 characters in body
|
Jul 21, 2011 at 12:18 | history | edited | user1228 | CC BY-SA 3.0 |
added 437 characters in body
|
Jan 26, 2009 at 18:35 | history | edited | user1228 | CC BY-SA 2.5 |
added 2013 characters in body
|
Jan 26, 2009 at 14:09 | history | edited | user1228 | CC BY-SA 2.5 |
deleted 22 characters in body
|
Jan 26, 2009 at 14:07 | vote | accept | Yaakov Ellis | ||
Jan 26, 2009 at 13:18 | history | edited | user1228 | CC BY-SA 2.5 |
added 349 characters in body
|
Jan 26, 2009 at 13:11 | history | edited | user1228 | CC BY-SA 2.5 |
HURRRR
|
Jan 26, 2009 at 13:03 | history | answered | user1228 | CC BY-SA 2.5 |