public class ToBase extends PostfixMathCommand
Long.toString(long, int)curNumberOfParameters, numberOfParameters| Constructor 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.
|
checkStack, getNumberOfParameters, setCurNumberOfParameterspublic 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)
PostfixMathCommandcheckNumberOfParameters in interface PostfixMathCommandIcheckNumberOfParameters in class PostfixMathCommandn - number of parameters function will be called with.public void run(Stack s) throws ParseException
PostfixMathCommandrun in interface PostfixMathCommandIrun in class PostfixMathCommandParseExceptionpublic 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 > 36Copyright © 2018. All rights reserved.