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