Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- namespace ConsoleApp.ExtMethods
- {
- public static class DoubleExtentions
- {
- public static int IntPart(this double value)
- {
- return (int)Math.Truncate(value);
- }
- public static int FractPart(this double value)
- {
- var str = value.ToString();
- int sepIndex = str.LastIndexOf(Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator);
- return (sepIndex != -1) ? int.Parse(str.Substring(sepIndex + 1)) : 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement