Advertisement
gr4viton

type safety vs delka kodu

Mar 19th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1.  
  2. private double GET_bounded(double val, double min, double max)
  3. {
  4. if (val > max)
  5. {
  6. LOG(String.Format(
  7. "Value out of bounds: bigger then boundary {0} > [max{1}]",
  8. val, max));
  9. return max;
  10. }
  11. else if (val < min)
  12. {
  13. LOG(String.Format(
  14. "Value out of bounds: lower then boundary {0} < [min{1}]",
  15. val, min));
  16. return min;
  17. }
  18. else
  19. {
  20. return val;
  21. }
  22. }
  23.  
  24. private byte GET_bounded(byte val, byte min, byte max)
  25. {
  26. if (val > max)
  27. {
  28. LOG(String.Format(
  29. "Value out of bounds: bigger then boundary {0} > [max{1}]",
  30. val, max));
  31. return max;
  32. }
  33. else if (val < min)
  34. {
  35. LOG(String.Format(
  36. "Value out of bounds: lower then boundary {0} < [min{1}]",
  37. val, min));
  38. return min;
  39. }
  40. else
  41. {
  42. return val;
  43. }
  44. }
  45.  
  46. jo mohl bych si ten string uložit.. ale to je tak všechno.. :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement