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