ptolemy.math
Class Precision.IntegerFractionPrecisionFormat
java.lang.Object
ptolemy.math.Precision.PrecisionFormat
ptolemy.math.Precision.IntegerFractionPrecisionFormat
- Enclosing class:
- Precision
public static class Precision.IntegerFractionPrecisionFormat
- extends Precision.PrecisionFormat
Defines a Precision string format using the INTEGER.FRACTION
precision format. The INTEGER value specifies the number of
integer bits and the FRACTION value specifies the number of
fractional bits. Negative values are allowed for either INTEGER
or FRACTION (but not both).
This format supports the specification of either signed or
unsigned values. The character 'U' must precede the
integer.fraction format to specify an unsigned value. An 'S' character
may be applied to specify a signed number. If no 'U' or 'S'
signed specification is provided, the precision will default
to a signed value.
The exponent in this format is set to -fraction.
Parenthesis or brackets are optional around this specification.
Examples:
- (3.5)
- (U2.1)
- [S2.1]
- [S6.-2]
- S-2.4
When printed, this format will always use parenthesis and
only use the signed format specification for unsigned numbers
(i.e. 'U' used for unsigned numbers and NO 'S' for signed
numbers).
Field Summary |
protected static java.lang.String |
_regex
Regular expression for IntegerFractionPrecisionFormat. |
Method Summary |
Precision |
parseString(java.lang.String str)
Parse the given String argument using the rules of the specific
PrecisionFormat that is defined. |
java.lang.String |
printPrecisionFormat(Precision p)
Creates a valid String representation of the Precision object
based on the rules of the given string format. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_regex
protected static final java.lang.String _regex
- Regular expression for IntegerFractionPrecisionFormat.
Example: (S3.2)
- See Also:
- Constant Field Values
Precision.IntegerFractionPrecisionFormat
public Precision.IntegerFractionPrecisionFormat()
parseString
public Precision parseString(java.lang.String str)
throws java.lang.IllegalArgumentException
- Description copied from class:
Precision.PrecisionFormat
- Parse the given String argument using the rules of the specific
PrecisionFormat that is defined. This method will return a
valid Precision object from the String. If the String parsing
does not produce a valid match, this method will return a null.
If the String match is successful but there is a problem in
the interpretation of the match, this method will throw
a IllegalArgumentException.
- Specified by:
parseString
in class Precision.PrecisionFormat
- Parameters:
str
- String to parse
- Returns:
- A Precision object. Returns a null if the String does
not match the particular string format.
- Throws:
java.lang.IllegalArgumentException
- If there is a problem
parsing the String (i.e. an illegal string).
printPrecisionFormat
public java.lang.String printPrecisionFormat(Precision p)
- Description copied from class:
Precision.PrecisionFormat
- Creates a valid String representation of the Precision object
based on the rules of the given string format. The format of this
String should be consistent with the format used in the
parseString method.
- Specified by:
printPrecisionFormat
in class Precision.PrecisionFormat
- Parameters:
p
- Precision object to represent as a String.
- Returns:
- String representing the Precision object