Alternative Radices

Representing an integer value with a specified radix.

Overview

In this assignment, you will implement and test a method that constructs a String representation of a specified long value, using a specified radix (number base).

Implementation

Declaration

In the edu.cnm.deepdive.Radices class, the toString method is declared with the following signature, return type, and modifiers:

public static String toString(long value, int radix) throws IllegalArgumentException

The implementation must not change the modifiers, return type, method name, parameter types/number/order, or possible exceptions shown above. For more method declaration details, see the Javadoc documentation.

Specifications

Tips

Unit tests

The following test cases will be used for unit testing the Radices.toString method.

value radix Expected return value of Radices.toString(value, radix) Expected exception
-250 2 "-11111010" (none)
1000 5 "13000" (none)
-5_000 7 "-20402" (none)
7_500 8 "16514" (none)
-100_000 16 "-186a0" (none)
2_000_000 20 "ca000" (none)
5_000_000_000 36 "2aovcow" (none)
0 2 "0" (none)
0 10 "0" (none)
10 1 (none) IllegalArgumentException
100 0 (none) IllegalArgumentException
1_000 -2 (none) IllegalArgumentException
10_000 40 (none) IllegalArgumentException
  1. See “Alternative Radices: Conversions Between Radices” for a pseudocode expression of an algorithm to construct a representation of an integral value in any integral base greater than or equal to 2.