MathUtilities.java 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /**
  2. * Created by dan on 6/14/17.
  3. */
  4. public class MathUtilities {
  5. /**
  6. * @param baseValue starting value
  7. * @param difference value to add to starting value
  8. * @return sum of `baseValue` and `difference`
  9. */
  10. public Integer add(int baseValue, int difference) {
  11. int result = baseValue + difference;
  12. return result;
  13. }
  14. /**
  15. * @param baseValue starting value
  16. * @param difference value to add to starting value
  17. * @return sum of `baseValue` and `difference`
  18. */
  19. public Long add(long baseValue, long difference) {
  20. long result = baseValue + difference;
  21. return result;
  22. }
  23. /**
  24. * @param baseValue starting value
  25. * @param difference value to add to starting value
  26. * @return sum of `baseValue` and `difference`
  27. */
  28. public Short add(short baseValue, short difference) {
  29. short result = (short) (baseValue + difference);
  30. return result;
  31. }
  32. /**
  33. * @param baseValue starting value
  34. * @param difference value to add to starting value
  35. * @return sum of `baseValue` and `difference`
  36. */
  37. public Byte add(byte baseValue, byte difference) {
  38. byte result = (byte) (baseValue + difference);
  39. return result;
  40. }
  41. /**
  42. * @param baseValue starting value
  43. * @param difference value to add to starting value
  44. * @return sum of `baseValue` and `difference`
  45. */
  46. public Float add(float baseValue, float difference) {
  47. float result = baseValue + difference;
  48. return result;
  49. }
  50. /**
  51. * @param baseValue starting value
  52. * @param difference value to add to starting value
  53. * @return sum of `baseValue` and `difference`
  54. */
  55. public Double add(double baseValue, double difference) {
  56. double result = baseValue + difference;
  57. return result;
  58. }
  59. /**
  60. * @param baseValue starting value
  61. * @param difference value to subtract from starting value
  62. * @return difference between `baseValue` and `difference`
  63. */
  64. public Integer subtract(int baseValue, int difference) {
  65. int result = baseValue - difference;
  66. return result;
  67. }
  68. /**
  69. * @param baseValue starting value
  70. * @param difference value to subtract from starting value
  71. * @return difference between `baseValue` and `difference`
  72. */
  73. public Long subtract(long baseValue, long difference) {
  74. long result = baseValue - difference;
  75. return result;
  76. }
  77. /**
  78. * @param baseValue starting value
  79. * @param difference value to subtract from starting value
  80. * @return difference between `baseValue` and `difference`
  81. */
  82. public Short subtract(short baseValue, short difference) {
  83. short result = (short) (baseValue - difference);
  84. return result;
  85. }
  86. /**
  87. * @param baseValue starting value
  88. * @param difference value to subtract from starting value
  89. * @return difference between `baseValue` and `difference`
  90. */
  91. public Byte subtract(byte baseValue, byte difference) {
  92. byte result = (byte) (baseValue - difference);
  93. return result;
  94. }
  95. /**
  96. * @param baseValue starting value
  97. * @param difference value to subtract from starting value
  98. * @return difference between `baseValue` and `difference`
  99. */
  100. public Float subtract(float baseValue, float difference) {
  101. float result = baseValue - difference;
  102. return result;
  103. }
  104. /**
  105. * @param baseValue starting value
  106. * @param difference value to subtract from starting value
  107. * @return difference between `baseValue` and `difference`
  108. */
  109. public Double subtract(double baseValue, double difference) {
  110. double result = baseValue - difference;
  111. return result;
  112. }
  113. /**
  114. * @param dividend value to be divided
  115. * @param divisor value to divide by
  116. * @return division of `dividend` by `divisor
  117. */
  118. public Integer divide(int dividend, int divisor) {
  119. int result = dividend/divisor;
  120. return result;
  121. }
  122. /**
  123. * @param dividend value to be divided
  124. * @param divisor value to divide by
  125. * @return division of `dividend` by `divisor
  126. */
  127. public Long divide(long dividend, long divisor) {
  128. long result = dividend/divisor;
  129. return result;
  130. }
  131. /**
  132. * @param dividend value to be divided
  133. * @param divisor value to divide by
  134. * @return division of `dividend` by `divisor
  135. */
  136. public Short divide(short dividend, short divisor) {
  137. short result = (short) (dividend/divisor);
  138. return result;
  139. }
  140. /**
  141. * @param dividend value to be divided
  142. * @param divisor value to divide by
  143. * @return division of `dividend` by `divisor
  144. */
  145. public Byte divide(byte dividend, byte divisor) {
  146. byte result = (byte) (dividend/divisor);
  147. return result;
  148. }
  149. /**
  150. * @param dividend value to be divided
  151. * @param divisor value to divide by
  152. * @return division of `dividend` by `divisor
  153. */
  154. public Float divide(float dividend, float divisor) {
  155. float result = dividend/divisor;
  156. return result;
  157. }
  158. /**
  159. * @param dividend value to be divided
  160. * @param divisor value to divide by
  161. * @return division of `dividend` by `divisor
  162. */
  163. public Double divide(double dividend, double divisor) {
  164. double result = dividend/divisor;
  165. return result;
  166. }
  167. /**
  168. * @param multiplicand value to be multiplied
  169. * @param multiplier value to multiply by
  170. * @return product of `multiplicand` by `multiplier`
  171. */
  172. public Integer multiply(int multiplicand, int multiplier) {
  173. int result = multiplicand*multiplier;
  174. return result;
  175. }
  176. /**
  177. * @param multiplicand value to be multiplied
  178. * @param multiplier value to multiply by
  179. * @return product of `multiplicand` by `multiplier`
  180. */
  181. public Long multiply(long multiplicand, long multiplier) {
  182. long result = multiplicand*multiplier;
  183. return result;
  184. }
  185. /**
  186. * @param multiplicand value to be multiplied
  187. * @param multiplier value to multiply by
  188. * @return product of `multiplicand` by `multiplier`
  189. */
  190. public Short multiply(short multiplicand, short multiplier) {
  191. short result = (short) (multiplicand*multiplier);
  192. return result;
  193. }
  194. /**
  195. * @param multiplicand value to be multiplied
  196. * @param multiplier value to multiply by
  197. * @return product of `multiplicand` by `multiplier`
  198. */
  199. public Byte multiply(byte multiplicand, byte multiplier) {
  200. byte result = (byte) (multiplicand*multiplier);
  201. return result;
  202. }
  203. /**
  204. * @param multiplicand value to be multiplied
  205. * @param multiplier value to multiply by
  206. * @return product of `multiplicand` by `multiplier`
  207. */
  208. public Float multiply(float multiplicand, float multiplier) {
  209. float result = multiplicand*multiplier;
  210. return result;
  211. }
  212. /**
  213. * @param multiplicand value to be multiplied
  214. * @param multiplier value to multiply by
  215. * @return product of `multiplicand` by `multiplier`
  216. */
  217. public Double multiply(double multiplicand, double multiplier) {
  218. double result = multiplicand*multiplier;
  219. return result;
  220. }
  221. /**
  222. * @return true
  223. */
  224. public Boolean returnTrue() {
  225. return true;
  226. }
  227. /**
  228. * @return false
  229. */
  230. public Boolean returnFalse() {
  231. return false;
  232. }
  233. }