ssGetDataTypeIsScalingPow2
Determine whether registered data type has power-of-two scaling
Syntax
extern int ssGetDataTypeIsScalingPow2 (SimStruct *S, DTypeId dataTypeId)
Arguments
S
SimStruct representing an S-function block.
dataTypeId
Data type ID of the registered data type for which you want to know whether the scaling is strictly power-of-two.
Description
This function determines whether the registered data type is scaled strictly by a power of two. Fixed-point numbers can be represented as
real-world value = (slope × integer) + bias,
where the slope can be expressed as
slope = fractional slope × 2exponent.
When bias = 0 and fractional slope = 1, the only scaling factor that remains is a power of two:
real-world value = (2exponent × integer) = (2-fraction length × integer).
Trivial scaling is considered a case of power-of-two scaling, with the exponent being equal to zero.
Note
Many fixed-point algorithms are designed to accept only power-of-two
scaling. For these algorithms, you can call
ssGetDataTypeIsScalingPow2
in mdlSetInputPortDataType
and mdlSetOutputPortDataType
,
to prevent unsupported data types from being accepted.
This function errors out when ssGetDataTypeIsFxpFltApiCompat
returns
FALSE
.
Requirement
To use this function, you must include fixedpoint.h
and
fixedpoint.c
. For more information, see Structure of the S-Function.
Languages
C
TLC Functions
FixPt_DataTypeIsScalingPow2
See Also
Version History
Introduced before R2006a