# Math¶

## Data Type Min and Data Type Max¶

These components output the minimum or maximum value of a numeric data type. The components are
polymorphic and can be used with both integer and floating point types. (For
floating point types, the output will be positive or negative `Infinity`

, as appropriate.) The implementations of
these components illustrate the saturation behavior of the Nearest primitive component, where a value whose magnitude is
too large to fit in the destination data type is clipped to fit inside the available range.

## Limit¶

This is a simple component implementing a common behavior needed in signal processing: clipping a value to a given range. The example implementation uses CertSAFE’s Min/Max Selector component. A limiter with only a lower bound is equivalent to a Max Selector, while a limiter with only an upper bound is equivalent to a Min Selector, so combining the two of them clips the input with both a lower and an upper bound. The order of operations (min then max vs. max then min) is irrelevant unless the lower bound input is greater than the upper bound input, which presumably cannot happen in most cases.

## Saturating Increment¶

This component returns 1 plus the input value, computed using saturation arithmetic. Floating point data types in CertSAFE use saturation arithmetic automatically, so for these data types this component is equivalent to using an Inline Adder primitive with a literal value of 1. However, for integer data types, this component behaves differently than the Inline Adder primitive when given the data type’s maximum value as input. The addition performed by the Inline Adder primitive will silently overflow and output the data type’s minimum value, whereas the Saturating Increment component will output the data type’s maximum value. This behavior is useful when implementing components where arithmetic overflow is inappropriate. Several counter components in this example library use the Saturating Arithmetic component internally so that timers implemented using these components behave sensibly in long simulations.