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

## org.lsmp.djep.xjep.function
Class ToBase

    java.lang.Object
      org.nfunk.jep.function.PostfixMathCommand
          org.lsmp.djep.xjep.function.ToBase

All Implemented Interfaces:
  PostfixMathCommandI

    public class ToBase

extends PostfixMathCommand

Convert a number to a string in a given base. toBase(val,12) converts to base 12 numbers. toBase(val,16,3) converts to base 12 with 3 hex digits after decimal place. toHex(val) converts to base 16 toHex(val,3) converts to base 16 with 3 hex digits after decimal place. A prefix can be specified in the constructor. If set this will be appended to the number (after minus sign for negative values).

Author:
  Rich Morris Created on 02-May-2005
See Also:
  `Long.toString(long, int)`

Field Summary

Fields inherited from class org.nfunk.jep.function.PostfixMathCommand
`curNumberOfParameters, numberOfParameters`

Constructor Summary
`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.

Method Summary
`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.

Methods inherited from class org.nfunk.jep.function.PostfixMathCommand
`checkStack, getNumberOfParameters, setCurNumberOfParameters`

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

Constructor Detail

### ToBase

    public ToBase()

  Constructor where base is specified as a function argument.

### ToBase

    public ToBase(int base)

  Constructor with specified base.

  Parameters:
    `base` - the base to use
  Throws:
    `java.lang.IllegalArgumentException` - if base is < 2 or > 36

### ToBase

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

  Constructor with specified base and a given prefix. For example 0x to proceed hexadecimal numbers.

  Parameters:
    `base` - the base to use
    `prefix` - the string to prefix numbers with.
  Throws:
    `java.lang.IllegalArgumentException` - if base is < 2 or > 36

Method Detail

### checkNumberOfParameters

    public boolean checkNumberOfParameters(int n)

  Description copied from class: `PostfixMathCommand`
  Checks the number of parameters of the function. Functions which set numberOfParameter=-1 should overload this method

  Specified by:
    `checkNumberOfParameters` in interface `PostfixMathCommandI`
  Overrides:
    `checkNumberOfParameters` in class `PostfixMathCommand`
  Parameters:
    `n` - number of parameters function will be called with.
  Returns:
    False if an illegal number of parameters is supplied, true otherwise.

### run

    public void run(java.util.Stack s)
             throws ParseException

  Description copied from class: `PostfixMathCommand`
  Throws an exception because this method should never be called under normal circumstances. Each function should use it's own run() method for evaluating the function. This includes popping off the parameters from the stack, and pushing the result back on the stack.

  Specified by:
    `run` in interface `PostfixMathCommandI`
  Overrides:
    `run` in class `PostfixMathCommand`
  Throws:
    `ParseException`

### toBase

    public java.lang.String toBase(long num,
                                   int base)

  Converts a number to a give base.

  Parameters:
    `num` - number to convert
    `base` - base to use
  Returns:
    String representation
  Throws:
    `java.lang.IllegalArgumentException` - if base is < 2 or > 36

### toBase

    public java.lang.String toBase(double val,
                                   int base,
                                   int digits)

  Converts a number to a give base.

  Parameters:
    `val` - number to convert
    `base` - base to use
    `digits` - number of digits after decimal place
  Returns:
    String representation
  Throws:
    `java.lang.IllegalArgumentException` - if base is < 2 or > 36

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

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