AnsweredAssumed Answered

About data type converting (tFrac16 -> float(maybe) -> tFrac16) in AN5201SW application SW

Question asked by SuBin Kim on Feb 4, 2018
Latest reply on Feb 19, 2018 by Matej Pacha

Hi,

 

My codewarrior version is 10.6 and studying about AN5201SW now.

 

In my application, I want to calculate (tFrac16 type value * 3.2767) and get result again in tFrac16 type.

 

tFrac16 type value is between 0 and 10,000, so I expect that it does not exceed the express range of result_value.

 

How can I do this? please give me a hand.

 

For additional explanation(in AN5201SW)

I want to calculate  ((tFrac16)requiredSpeed * (float)3.2767  = (tFrac16)RESULT_VALUE) in "AppRun" step.

 

"SWLIBS_Typedefs.h"

typedef unsigned char       tU8;            /*!< unsigned 8-bit integer type */
typedef signed char         tS8;            /*!< signed 8-bit integer type */
typedef unsigned short      tU16;           /*!< unsigned 16-bit integer type */
typedef signed short        tS16;           /*!< signed 16-bit integer type */
typedef unsigned long       tU32;           /*!< unsigned 32-bit integer type */
typedef signed long         tS32;           /*!< signed 32-bit integer type */
typedef signed long long    tS64;           /*!< signed 64-bit integer type */
typedef tS16                tFrac16;        /*!< 16-bit signed fractional Q1.15 type */
typedef tS32                tFrac32;        /*!< 32-bit Q1.31 type */
typedef float               tFloat;         /*!< single precision float type */

Outcomes