Class FixToFix

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class FixToFix
    extends Converter
    This actor converts a FixToken into another FixToken with a specified precision. Note that this conversion may be lossy, in that the output may be an approximation of the input. The approximation can be constructed using a variety of rounding and overflow strategies,

    The precision of the output is given by the precision parameter, which is an integer matrix of the form [m, n], where the total number of bits in the output is m, of which n are integer bits. The default precision is [16, 2], which means that an output has 16 bits, of which 2 bits represent the integer part.

    The rounding strategy is defined by the rounding parameter and defaults to nearest (or half_floor), selecting the nearest representable value. The floor value nearer to minus infinity is used for values half way between representable values. Other strategies such as truncate are described under ptolemy.math.Rounding.

    The overflow strategy is defined by the overflow parameter and defaults to saturate (or clip). Out of range values are saturated to the nearest representable value. Other strategies such as modulo are described under ptolemy.math.Overflow.

    Since:
    Ptolemy II 1.0
    Version:
    $Id$
    Author:
    Bart Kienhuis, Edward A. Lee, Ed Willink
    See Also:
    FixToken, Overflow, Precision, Rounding
    Pt.AcceptedRating:
    Green (pwhitake)
    Pt.ProposedRating:
    Green (pwhitake)
    • Field Detail

      • precision

        public Parameter precision
        The precision of the output fix-point number, represented by an integer matrix.
      • rounding

        public StringAttribute rounding
        The rounding strategy used, such as "nearest" or "truncate".
      • overflow

        public StringAttribute overflow
        The overflow strategy used to convert a double into a fix point, such as "saturate" or "to_zero".