{"id":"iec-shr","model_id":"SHR","name":"CODESYS SHR","summary":"SHR is an IEC bitwise shift operator that moves the bits of an operand to the right by a given number of places. It is written as erg := SHR (in, n), where in is the operand being shifted and n is the number of bit positions to shift. The result is assigned to the output variable erg, as shown in the structured text example where 16#45 shifted right by 2 gives 16#11.","study_notes":["SHR operates on bit strings; the example shifts a BYTE (16#45, 2#01000101) and a WORD (16#0045, 2#0000000001000101).","With n = 2, SHR(in_byte, n) returns 16#11 (2#00010001) and SHR(in_word, n) returns 16#0011 (2#0000000000010001).","If n exceeds the data type width, how BYTE, WORD, DWORD and LWORD operands are padded depends on the target system: padding is either with zeros or by n MOD <register size>.","The operator is demonstrated in a structured text (ST) program and also shown in FBD form."],"safety_notes":[],"sources":[{"url":"https://infosys.beckhoff.com/content/1033/tc3_plc_intro/2528939915.html","title":"Beckhoff Information System","accessed":"2026-10-26"},{"url":"https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_operator_shr.html","title":"CODESYS Group","accessed":"2026-10-26"}],"verification":{"status":"source_checked","checked_at":"2026-10-26","values":7,"method":"llm_source_check"},"updated_at":"2026-10-26","type":"instruction","spec":{"language":"structured_text","code":"SHR","group":"bitwise shift","syntax":"erg := SHR (in, n)","parameters":[{"name":"in","description":"Operand which is shifted to the right"},{"name":"n","description":"Number of bits to shift in to the right"}],"dialect":"CODESYS","related":[],"standards":[]},"url":"https://machineschema.com/instruction/iec-shr","license":"https://creativecommons.org/licenses/by/4.0/"}