123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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 addedValue ) {
  11. int sum;
  12. sum= baseValue + addedValue;
  13. return sum;
  14. }
  15. /**
  16. * @param baseValue starting value
  17. * @param difference value to add to starting value
  18. * @return sum of `baseValue` and `difference`
  19. */
  20. public Long add(long baseValue, long difference) {
  21. long diff= baseValue + difference;
  22. return diff;
  23. }
  24. /**
  25. * @param baseValue starting value
  26. * @param difference value to add to starting value
  27. * @return sum of `baseValue` and `difference`
  28. */
  29. public Short add(short baseValue, short addedValue) {
  30. return (short)(baseValue + addedValue);
  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 addedValue) {
  38. return (byte)(baseValue + addedValue);
  39. }
  40. /**
  41. * @param baseValue starting value
  42. * @param difference value to add to starting value
  43. * @return sum of `baseValue` and `difference`
  44. */
  45. public Float add(float baseValue, float addedValue) {
  46. return (float)(baseValue + addedValue);
  47. }
  48. /**
  49. * @param baseValue starting value
  50. * @param difference value to add to starting value
  51. * @return sum of `baseValue` and `difference`
  52. */
  53. public Double add(double baseValue, double addedValue) {
  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. return (int)(baseValue - difference);
  63. }
  64. /**
  65. * @param baseValue starting value
  66. * @param difference value to subtract from starting value
  67. * @return difference between `baseValue` and `difference`
  68. */
  69. public Long subtract(long baseValue, long difference) {
  70. return (long)(baseValue - difference);
  71. }
  72. /**
  73. * @param baseValue starting value
  74. * @param difference value to subtract from starting value
  75. * @return difference between `baseValue` and `difference`
  76. */
  77. public Short subtract(short baseValue, short difference) {
  78. return (short)(baseValue - difference);
  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. return (byte)(baseValue - difference);
  87. }
  88. /**
  89. * @param baseValue starting value
  90. * @param difference value to subtract from starting value
  91. * @return difference between `baseValue` and `difference`
  92. */
  93. public Float subtract(float baseValue, float difference) {
  94. return (float)(baseValue - difference);
  95. }
  96. /**
  97. * @param baseValue starting value
  98. * @param difference value to subtract from starting value
  99. * @return difference between `baseValue` and `difference`
  100. */
  101. public Double subtract(double baseValue, double difference) {
  102. return (double)(baseValue - difference);
  103. }
  104. /**
  105. * @param dividend value to be divided
  106. * @param divisor value to divide by
  107. * @return division of `dividend` by `divisor
  108. */
  109. public Integer divide(int dividend, int divisor) {
  110. return (int)(dividend / divisor);
  111. }
  112. /**
  113. * @param dividend value to be divided
  114. * @param divisor value to divide by
  115. * @return division of `dividend` by `divisor
  116. */
  117. public Long divide(long dividend, long divisor) {
  118. return (long)(dividend / divisor);
  119. }
  120. /**
  121. * @param dividend value to be divided
  122. * @param divisor value to divide by
  123. * @return division of `dividend` by `divisor
  124. */
  125. public Short divide(short dividend, short divisor) {
  126. return (short) ( 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 Byte divide(byte dividend, byte divisor) {
  134. return (byte)(dividend / divisor);
  135. }
  136. /**
  137. * @param dividend value to be divided
  138. * @param divisor value to divide by
  139. * @return division of `dividend` by `divisor
  140. */
  141. public Float divide(float dividend, float divisor) {
  142. return (float)(dividend / divisor);
  143. }
  144. /**
  145. * @param dividend value to be divided
  146. * @param divisor value to divide by
  147. * @return division of `dividend` by `divisor
  148. */
  149. public Double divide(double dividend, double divisor) {
  150. return (double)(dividend / divisor);
  151. }
  152. /**
  153. * @param multiplicand value to be multiplied
  154. * @param multiplier value to multiply by
  155. * @return product of `multiplicand` by `multiplier`
  156. */
  157. public Integer multiply(int multiplicand, int multiplier) {
  158. return (int)(multiplicand * multiplier);
  159. }
  160. /**
  161. * @param multiplicand value to be multiplied
  162. * @param multiplier value to multiply by
  163. * @return product of `multiplicand` by `multiplier`
  164. */
  165. public Long multiply(long multiplicand, long multiplier) {
  166. return (long)(multiplicand * multiplier);
  167. }
  168. /**
  169. * @param multiplicand value to be multiplied
  170. * @param multiplier value to multiply by
  171. * @return product of `multiplicand` by `multiplier`
  172. */
  173. public Short multiply(short multiplicand, short multiplier) {
  174. return (short)(multiplicand * multiplier);
  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 Byte multiply(byte multiplicand, byte multiplier) {
  182. return (byte)(multiplicand * multiplier);
  183. }
  184. /**
  185. * @param multiplicand value to be multiplied
  186. * @param multiplier value to multiply by
  187. * @return product of `multiplicand` by `multiplier`
  188. */
  189. public Float multiply(float multiplicand, float multiplier) {
  190. return (float)(multiplicand * multiplier);
  191. }
  192. /**
  193. * @param multiplicand value to be multiplied
  194. * @param multiplier value to multiply by
  195. * @return product of `multiplicand` by `multiplier`
  196. */
  197. public Double multiply(double multiplicand, double multiplier) {
  198. return (double)(multiplicand * multiplier);
  199. }
  200. /**
  201. * @return true
  202. */
  203. public Boolean returnTrue() {
  204. return true;
  205. }
  206. /**
  207. * @return false
  208. */
  209. public Boolean returnFalse() {
  210. return false;
  211. }
  212. }