Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.singularsys.jep.misc.functions
Class FromBase

    java.lang.Object
      com.singularsys.jep.functions.PostfixMathCommand
          com.singularsys.jep.misc.functions.FromBase

All Implemented Interfaces:
  PostfixMathCommandI, java.io.Serializable

    public class FromBase

extends PostfixMathCommand

PostfixMathCommand which converts a string to a number in a given base. Instance of these classes can be specified with two different behaviours either with the base specified in the constructor or with no base specified in which case the function requires two arguments, the second of which is the base. A third form allows a prefix to be specified, this prefix must be present in the jep expression.

For example

    jep.addFunction("fromDec",new FromBase(10));
     jep.parse("fromDec(\"123.45\")");
     jep.addFunction("fromHex",new FromBase(16,"0x"));
     jep.parse("fromHex(\"0xff\")");
     jep.addFunction("fromBase",new FromBase());
     jep.parse("fromBase(\"0377\",8)");

Author:
  Rich Morris Created on 02-May-2005
See Also:
  Serialized Form

Field Summary

Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
`curNumberOfParameters, name, NaN, numberOfParameters`

Constructor Summary
`FromBase()`
`FromBase(int base)`
`FromBase(int base, java.lang.String prefix)`

Method Summary
`java.lang.Object` | `fromBase(java.lang.String str, int base)`
`void` | `run(java.util.Stack<java.lang.Object> s)` Run the function on the stack.

Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
`asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkNumberOfParameters, checkStack, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FromBase

    public FromBase()

### FromBase

    public FromBase(int base)

### FromBase

    public FromBase(int base,
                    java.lang.String prefix)

Method Detail

### run

    public void run(java.util.Stack<java.lang.Object> s)
             throws EvaluationException

  Description copied from interface: `PostfixMathCommandI`
  Run the function on the stack. Pops the arguments from the stack, and pushes the result on the top of the stack.

  Throws:
    `EvaluationException`

### fromBase

    public java.lang.Object fromBase(java.lang.String str,
                                     int base)
                              throws java.lang.NumberFormatException

  Throws:
    `java.lang.NumberFormatException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 Singular Systems http://www.singularsys.com/jep