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,
java.lang.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(java.util.Stack s)
Throws an exception because this method should never be called under
normal circumstances.
|
java.lang.String |
toBase(double val,
int base,
int digits)
Converts a number to a give base.
|
java.lang.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 usejava.lang.IllegalArgumentException - if base is < 2 or > 36public ToBase(int base,
java.lang.String prefix)
base - the base to useprefix - the string to prefix numbers with.java.lang.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(java.util.Stack s)
throws ParseException
PostfixMathCommandrun in interface PostfixMathCommandIrun in class PostfixMathCommandParseExceptionpublic java.lang.String toBase(long num,
int base)
num - number to convertbase - base to usejava.lang.IllegalArgumentException - if base is < 2 or > 36public java.lang.String toBase(double val,
int base,
int digits)
val - number to convertbase - base to usedigits - number of digits after decimal placejava.lang.IllegalArgumentException - if base is < 2 or > 36http://www.singularsys.com/jep Copyright © 2007 Singular Systems