NumUnitExtensions.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Ips.Library.Basic
  5. {
  6. public static class NumUnitExtensions
  7. {
  8. public static int E3(this double source)
  9. {
  10. source = Math.Round(source, 6);
  11. return (int)(source * 1e3);
  12. }
  13. public static long E3l(this double source)
  14. {
  15. source = Math.Round(source, 6);
  16. return (long)(source * 1e3);
  17. }
  18. public static int E6(this double source)
  19. {
  20. source = Math.Round(source, 6);
  21. return (int)(source * 1e6);
  22. }
  23. public static long E6l(this double source)
  24. {
  25. source = Math.Round(source, 6);
  26. return (long)(source * 1e6);
  27. }
  28. public static double E3m(this int source)
  29. {
  30. return Math.Round(source * 1e-3, 3);
  31. }
  32. public static double E3m(this long source)
  33. {
  34. return Math.Round(source * 1e-3, 3);
  35. }
  36. public static double E6m(this int source)
  37. {
  38. return Math.Round(source * 1e-6, 6);
  39. }
  40. public static double E6m(this long source)
  41. {
  42. return Math.Round(source * 1e-6, 6);
  43. }
  44. }
  45. }