fork download
  1. using static System.Console;
  2. using static System.Decimal;
  3.  
  4. public class Test {
  5. public static void Main() {
  6. WriteLine(GetDecimalPart(45.545M));
  7. WriteLine(GetDecimalPart(45.54M));
  8. WriteLine(GetDecimalPart(0.545M));
  9. WriteLine(GetDecimalPart(-45.545M));
  10. WriteLine(GetDecimalPart(45.5450M));
  11. WriteLine(GetDecimalPart(999988776655.443322116M));
  12. }
  13.  
  14. static int GetDecimalPart(decimal value) {
  15. value = System.Math.Abs(value) - Floor(System.Math.Abs(value));
  16. do {
  17. value *= 10;
  18. } while (value != Floor(value));
  19. return (int)value;
  20. }
  21. }
  22.  
  23. //https://pt.stackoverflow.com/q/63881/101
Success #stdin #stdout 0.03s 24368KB
stdin
Standard input is empty
stdout
545
54
545
545
545
443322116