MathUtilities.java 6.8KB

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