public class ToBase extends PostfixMathCommand
Long.toString(long, int)
,
Serialized FormConstructor and Description |
---|
ToBase()
Constructor where base is specified as a function argument.
|
ToBase(int base)
Constructor with specified base.
|
ToBase(int base,
String prefix)
Constructor with specified base and a given prefix.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkNumberOfParameters(int n)
Checks the number of parameters of the function.
|
void |
run(Stack s)
Throws an exception because this method should never be called under
normal circumstances.
|
String |
toBase(double val,
int base,
int digits)
Converts a number to a give base.
|
String |
toBase(long num,
int base)
Converts a number to a give base.
|
getNumberOfParameters, setCurNumberOfParameters
public ToBase()
public ToBase(int base)
base
- the base to useIllegalArgumentException
- if base is < 2 or > 36public ToBase(int base, String prefix)
base
- the base to useprefix
- the string to prefix numbers with.IllegalArgumentException
- if base is < 2 or > 36public boolean checkNumberOfParameters(int n)
PostfixMathCommand
checkNumberOfParameters
in interface PostfixMathCommandI
checkNumberOfParameters
in class PostfixMathCommand
n
- number of parameters function will be called with.public void run(Stack s) throws ParseException
PostfixMathCommand
run
in interface PostfixMathCommandI
run
in class PostfixMathCommand
ParseException
public String toBase(long num, int base)
num
- number to convertbase
- base to useIllegalArgumentException
- if base is < 2 or > 36public String toBase(double val, int base, int digits)
val
- number to convertbase
- base to usedigits
- number of digits after decimal placeIllegalArgumentException
- if base is < 2 or > 36Jas4pp 1.5 © Java Analysis Studio for Particle Physics