flt2i32 — signed fractional number conversion into appropriate form for comparison operators.

Description:

i32 flt2i32(u32 value);

Returns signed fractional value converted to the form applicable for comparison operators (for example: converts fractional -20.5 into integer -5428). Later the obtained figure is possible to be used in comparison with data received from sensors.

List of parameters:

value

Unsigned fractional (fractional part is separated by a dot) Only literal.

Return values:

Returns signed integer. Type of return value u32.

Example:

<import-script id="512" TS="512:32" name="Test for flt2i32 function">
V-ID/s:2 
{
	i32 ms = flt2i32(-1.52);
	u8 strForMess[70]; 

	if([TS] > ms) 
	{
		sprintf(strForMess, "%c%d > %d", 1, [TS], ms);
	} 
	else
		if([TS] == ms) 
		{
			sprintf(strForMess, "%c%d = %d", 1, [TS], ms);
		} 
		else 
		{
			sprintf(strForMess, "%c%d less %d", 1, [TS], ms);
		}

	setStatus(2023:32, &strForMess);
}

</import-script>

The result of performing the example in the interface:

The message where the values of temperature sensor are compared with the value -1.52 is displayed in the interface every two seconds.

Note:

Only literal (figure not a variable) can be the parameter lvalue.