You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
1.2 KiB

11 years ago
  1. package common
  2. func MaxInt8(a, b int8) int8 {
  3. if a > b {
  4. return a
  5. }
  6. return b
  7. }
  8. func MaxUint8(a, b uint8) uint8 {
  9. if a > b {
  10. return a
  11. }
  12. return b
  13. }
  14. func MaxInt16(a, b int16) int16 {
  15. if a > b {
  16. return a
  17. }
  18. return b
  19. }
  20. func MaxUint16(a, b uint16) uint16 {
  21. if a > b {
  22. return a
  23. }
  24. return b
  25. }
  26. func MaxInt32(a, b int32) int32 {
  27. if a > b {
  28. return a
  29. }
  30. return b
  31. }
  32. func MaxUint32(a, b uint32) uint32 {
  33. if a > b {
  34. return a
  35. }
  36. return b
  37. }
  38. func MaxInt(a, b int) int {
  39. if a > b {
  40. return a
  41. }
  42. return b
  43. }
  44. func MaxUint(a, b uint) uint {
  45. if a > b {
  46. return a
  47. }
  48. return b
  49. }
  50. //-----------------------------------------------------------------------------
  51. func MinInt8(a, b int8) int8 {
  52. if a < b {
  53. return a
  54. }
  55. return b
  56. }
  57. func MinUint8(a, b uint8) uint8 {
  58. if a < b {
  59. return a
  60. }
  61. return b
  62. }
  63. func MinInt16(a, b int16) int16 {
  64. if a < b {
  65. return a
  66. }
  67. return b
  68. }
  69. func MinUint16(a, b uint16) uint16 {
  70. if a < b {
  71. return a
  72. }
  73. return b
  74. }
  75. func MinInt32(a, b int32) int32 {
  76. if a < b {
  77. return a
  78. }
  79. return b
  80. }
  81. func MinUint32(a, b uint32) uint32 {
  82. if a < b {
  83. return a
  84. }
  85. return b
  86. }
  87. func MinInt(a, b int) int {
  88. if a < b {
  89. return a
  90. }
  91. return b
  92. }
  93. func MinUint(a, b uint) uint {
  94. if a < b {
  95. return a
  96. }
  97. return b
  98. }