CAPL Script

InterpretAs

This reference collection includes Vector documentation reproduced with permission. Snippets may require configuration-specific symbols and are not all standalone programs. Sources and validation limits.

Syntax

dword interpretAsDword(float x);

float interpretAsFloat(dword x);

qword interpretAsQword(double x);

double interpretAsDouble(qword x);

Function

These functions interpret the actual bytes of a value as if the value was of another data type. InterpretAsFloatfor example takes the four bytes or a dword, interprets them as if they were four bytes of an IEEE single precision floating point number, and returns that number. InterpretAsDoubleinterprets eight bytes as if they were an IEEE double precision floating point number. InterpretAsDwordandInterpretAsQwordare the inverse functions.

Parameters

x The number which shall be interpreted.

Return Values

The interpreted value.

Reference example from the CANoe 12 help. Check the required configuration, database objects and API availability in your installed version; this is not a recorded compiler or runtime test.

// take a message with 8 bytes representing a double number
on message MessageWithDoubleSignal
{
  qword rawBytes;
  double value;
  rawBytes = this.qword(0);
  value = interpretAsDouble(rawBytes);
  write("The value is %g", value);
}