66/**
77 * Custom class representing a number that can be implemented as an {@code int},
88 * {@code long}, or {@code BigInteger}.
9- *
9+ *
1010 * @author <a href="mailto:[email protected] ">Vincenzo Arceri</a> 1111 * @author <a href="mailto:[email protected] ">Mattia 1212 * Merenda</a>
@@ -30,7 +30,7 @@ public enum Type {
3030
3131 /**
3232 * Builds a number starting from an integer value.
33- *
33+ *
3434 * @param i the integer value
3535 */
3636 public Number (int i ) {
@@ -50,7 +50,7 @@ public Number(BigInteger other) {
5050
5151 /**
5252 * Yields the backing implementation of the number.
53- *
53+ *
5454 * @return the backing implementation of the number
5555 */
5656 public Type getType () {
@@ -62,7 +62,7 @@ public Type getType() {
6262
6363 /**
6464 * Yields the integer value.
65- *
65+ *
6666 * @return the integer value
6767 */
6868 public int getInt () {
@@ -71,7 +71,7 @@ public int getInt() {
7171
7272 /**
7373 * Yields the big integer value.
74- *
74+ *
7575 * @return the big integer value
7676 */
7777 public BigInteger getBigInteger () {
@@ -90,9 +90,9 @@ public static BigInteger toBigInteger(Number other) {
9090
9191 /**
9292 * Adds two numbers and returns the result as a {@code Number}.
93- *
93+ *
9494 * @param other the number to add
95- *
95+ *
9696 * @return the sum as a {@code Number}
9797 */
9898 public Number add (Number other ) {
@@ -107,9 +107,9 @@ public Number add(Number other) {
107107
108108 /**
109109 * Subtracts another number from this one and returns the result.
110- *
110+ *
111111 * @param other the number to subtract
112- *
112+ *
113113 * @return the result as a {@code Number}
114114 */
115115 public Number subtract (Number other ) {
@@ -124,9 +124,9 @@ public Number subtract(Number other) {
124124
125125 /**
126126 * Multiplies this number by another.
127- *
127+ *
128128 * @param other the number to multiply by
129- *
129+ *
130130 * @return the product as a {@code Number}
131131 */
132132 public Number multiply (Number other ) {
@@ -137,9 +137,9 @@ public Number multiply(Number other) {
137137
138138 /**
139139 * Multiplies this number by another.
140- *
140+ *
141141 * @param other the number to multiply by
142- *
142+ *
143143 * @return the product as a {@code Number}
144144 */
145145 public Number divide (Number other ) {
@@ -153,9 +153,9 @@ public Number divide(Number other) {
153153
154154 /**
155155 * Performs bitwise AND between two numbers.
156- *
156+ *
157157 * @param other the number to AND with
158- *
158+ *
159159 * @return the result as a {@code Number}
160160 */
161161 public Number and (Number other ) {
@@ -166,9 +166,9 @@ public Number and(Number other) {
166166
167167 /**
168168 * Performs bitwise OR between two numbers.
169- *
169+ *
170170 * @param other the number to OR with
171- *
171+ *
172172 * @return the result as a {@code Number}
173173 */
174174 public Number or (Number other ) {
@@ -179,9 +179,9 @@ public Number or(Number other) {
179179
180180 /**
181181 * Performs bitwise XOR between two numbers.
182- *
182+ *
183183 * @param other the number to XOR with
184- *
184+ *
185185 * @return the result as a {@code Number}
186186 */
187187 public Number xor (Number other ) {
@@ -204,7 +204,7 @@ public Number not() {
204204 * Computes the modulo of this number by another number.
205205 *
206206 * @param other the number to divide by
207- *
207+ *
208208 * @return the result as a {@code Number}
209209 */
210210 public Number modulo (Number other ) {
@@ -215,7 +215,7 @@ public Number modulo(Number other) {
215215
216216 /**
217217 * Converts this number into a byte array.
218- *
218+ *
219219 * @return the byte array representation
220220 */
221221 public byte [] toByteArray () {
@@ -225,9 +225,9 @@ public byte[] toByteArray() {
225225
226226 /**
227227 * Shifts this number right by a specified number of bits.
228- *
228+ *
229229 * @param other the number of positions to shift
230- *
230+ *
231231 * @return the shifted number
232232 */
233233 public Number shiftRight (int other ) {
@@ -237,9 +237,9 @@ public Number shiftRight(int other) {
237237
238238 /**
239239 * Shifts this number left by a specified number of bits.
240- *
240+ *
241241 * @param other the number of positions to shift
242- *
242+ *
243243 * @return the shifted number
244244 */
245245 public Number shiftLeft (int other ) {
@@ -258,6 +258,15 @@ public String toString() {
258258 return i + "" ;
259259 }
260260
261+ /**
262+ * Converts this number to a hexadecimal string representation.
263+ *
264+ * @return the hexadecimal string representation of this number
265+ */
266+ public String toHexString () {
267+ return toBigInteger (this ).toString (16 );
268+ }
269+
261270 @ Override
262271 public int compareTo (Number other ) {
263272 if (getType () == other .getType ()) {
0 commit comments