flt2u32 — unsigned fractional number conversion into appropriate form for comparison operators.

Description:

u32 flt2u32(u32 value);

Returns unsigned 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 unsigned integer. Type of return value u32.

Example:

<import-script id="512" MS="512:32" name="Test for flt2u32 function">

V-ID/s:2 
{
	u32 ms = flt2u32(20.5);
	u8 strForMess[70];

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

	setStatus(2023:32, &strForMess);
}

</import-script>

The result of performing the example in the interface:

The message where the values of motion sensor are compared with the value 20.5 is displayed in the interface every two seconds.

Note:

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