← Strings and Text

Weight With One Decimal

medium

Prints a weight with exactly one decimal place, '12.4' and not '12.3999996'.

What it teaches

A REAL holds most decimals only approximately: 12.4 is stored as 12.3999996185…, and RTOS prints it as '12.3999996'. Cutting that text after one decimal gives '12.3', because cutting never rounds. Storing a REAL in a DINT does round it, to the nearest whole number. Counted in tenths, 12.4 is the whole number 124, and with a point before its last digit it reads '12.4'. A weight below 1 has a single digit in tenths, 5 for 0.5, so it needs a 0 in front, as the serial number did in Serial Number Text, or it reads '.5'.

Parameters

TagDirectionTypeDefaultDescription
In_WeightInputREAL12.4The weight in kg, 0.0 to 9999.9
Ref_TextInOutSTRING—The weight as the ticket prints it

Required behavior