Test case R0002
Full test suiteDevice test case
Type conversions numeric
This test case it part of the test suite proposed for new devices.
Test case ID: R0002
Language: ST
tests2/t0002.st// Types conversions numeric PROGRAM T0002 VAR ibool : BOOL := BOOL#TRUE; isint : SINT := SINT#16#10; // 16 iint : INT := INT#16#3210; // 12816 idint : DINT := DINT#16#76543210; // 1985229328 ilint : LINT := LINT#16#999876543210; // 168880099308048 iuint : UINT := UINT#16#3210; // 12816 iusint : USINT := USINT#16#10; // 16 iudint : UDINT := UDINT#16#76543210; // 1985229328 iulint : ULINT := ULINT#16#999876543210; // 168880099308048 ireal : REAL := REAL#123.75; ilreal : LREAL := LREAL#124.75183; ibyte : BYTE := BYTE#16#10; // 16 iword : WORD := WORD#16#3210; // 12816 idword : DWORD := DWORD#16#76543210; // 1985229328 ilword : LWORD := LWORD#16#999876543210; // 168880099308048 obool : BOOL; osint : SINT; oint : INT; odint : DINT; olint : LINT; ouint : UINT; ousint : USINT; oudint : UDINT; oulint : ULINT; oreal : REAL; olreal : LREAL; obyte : BYTE; oword : WORD; odword : DWORD; olword : LWORD; END_VAR // ====== conversions from BOOL======= oword := BOOL_TO_WORD(ibool); ousint := BOOL_TO_USINT(ibool); oulint := BOOL_TO_ULINT(ibool); ouint := BOOL_TO_UINT(ibool); oudint := BOOL_TO_UDINT(ibool); osint := BOOL_TO_SINT(ibool); oreal := BOOL_TO_REAL(ibool); olword := BOOL_TO_LWORD(ibool); olreal := BOOL_TO_LREAL(ibool); olint := BOOL_TO_LINT(ibool); oint := BOOL_TO_INT(ibool); odword := BOOL_TO_DWORD(ibool); odint := BOOL_TO_DINT(ibool); obyte := BOOL_TO_BYTE(ibool); _GEB_ASSERT_EQFLOAT_(oreal,REAL#1.0); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#1.0); _GEB_ASSERT_(oword = WORD#16#1); _GEB_ASSERT_(ousint = USINT#1); _GEB_ASSERT_(oulint = ULINT#1); _GEB_ASSERT_(ouint = UINT#1); _GEB_ASSERT_(oudint = UDINT#1); _GEB_ASSERT_(osint = SINT#1); _GEB_ASSERT_(olword = LWORD#16#1); _GEB_ASSERT_(olint = LINT#1); _GEB_ASSERT_(oint = INT#1); _GEB_ASSERT_(odword = DWORD#16#1); _GEB_ASSERT_(odint = DINT#1); _GEB_ASSERT_(obyte = 16#1); // ====== conversions from BYTE======= oword := BYTE_TO_WORD(ibyte); ousint := BYTE_TO_USINT(ibyte); oulint := BYTE_TO_ULINT(ibyte); ouint := BYTE_TO_UINT(ibyte); oudint := BYTE_TO_UDINT(ibyte); osint := BYTE_TO_SINT(ibyte); oreal := BYTE_TO_REAL(ibyte); olword := BYTE_TO_LWORD(ibyte); olreal := BYTE_TO_LREAL(ibyte); olint := BYTE_TO_LINT(ibyte); oint := BYTE_TO_INT(ibyte); odword := BYTE_TO_DWORD(ibyte); odint := BYTE_TO_DINT(ibyte); obool := BYTE_TO_BOOL(ibyte); _GEB_ASSERT_EQFLOAT_(oreal,REAL#16.0); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#16.0); _GEB_ASSERT_(oword = WORD#16#10); _GEB_ASSERT_(ousint = USINT#16); _GEB_ASSERT_(oulint = ULINT#16); _GEB_ASSERT_(ouint = UINT#16); _GEB_ASSERT_(oudint = UDINT#16); _GEB_ASSERT_(osint = SINT#16); _GEB_ASSERT_(olword = LWORD#16#10); _GEB_ASSERT_(olint = LINT#16); _GEB_ASSERT_(oint = INT#16); _GEB_ASSERT_(odword = DWORD#16#10); _GEB_ASSERT_(odint = DINT#16); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from DINT======= oword := DINT_TO_WORD(idint); ousint := DINT_TO_USINT(idint); oulint := DINT_TO_ULINT(idint); ouint := DINT_TO_UINT(idint); oudint := DINT_TO_UDINT(idint); osint := DINT_TO_SINT(idint); oreal := DINT_TO_REAL(idint); olword := DINT_TO_LWORD(idint); olreal := DINT_TO_LREAL(idint); olint := DINT_TO_LINT(idint); oint := DINT_TO_INT(idint); odword := DINT_TO_DWORD(idint); obyte := DINT_TO_BYTE(idint); obool := DINT_TO_BOOL(idint); _GEB_ASSERT_EQFLOAT_(oreal,REAL#1.98523e+09); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#1.985229328e+09); _GEB_ASSERT_(oword = WORD#16#3210); _GEB_ASSERT_(ousint = USINT#16); _GEB_ASSERT_(oulint = ULINT#1985229328); _GEB_ASSERT_(ouint = UINT#12816); _GEB_ASSERT_(oudint = UDINT#1985229328); _GEB_ASSERT_(osint = SINT#16); _GEB_ASSERT_(olword = LWORD#16#76543210); _GEB_ASSERT_(olint = LINT#1985229328); _GEB_ASSERT_(oint = INT#12816); _GEB_ASSERT_(odword = DWORD#16#76543210); _GEB_ASSERT_(obyte = 16#10); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from DWORD======= oword := DWORD_TO_WORD(idword); ousint := DWORD_TO_USINT(idword); oulint := DWORD_TO_ULINT(idword); ouint := DWORD_TO_UINT(idword); oudint := DWORD_TO_UDINT(idword); osint := DWORD_TO_SINT(idword); oreal := DWORD_TO_REAL(idword); olword := DWORD_TO_LWORD(idword); olreal := DWORD_TO_LREAL(idword); olint := DWORD_TO_LINT(idword); oint := DWORD_TO_INT(idword); odint := DWORD_TO_DINT(idword); obyte := DWORD_TO_BYTE(idword); obool := DWORD_TO_BOOL(idword); _GEB_ASSERT_EQFLOAT_(oreal,REAL#1.98523e+09); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#1.985229328e+09); _GEB_ASSERT_(oword = WORD#16#3210); _GEB_ASSERT_(ousint = USINT#16); _GEB_ASSERT_(oulint = ULINT#1985229328); _GEB_ASSERT_(ouint = UINT#12816); _GEB_ASSERT_(oudint = UDINT#1985229328); _GEB_ASSERT_(osint = SINT#16); _GEB_ASSERT_(olword = LWORD#16#76543210); _GEB_ASSERT_(olint = LINT#1985229328); _GEB_ASSERT_(odint = DINT#1985229328); _GEB_ASSERT_(oint = INT#12816); _GEB_ASSERT_(obyte = 16#10); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from INT======= oword := INT_TO_WORD(iint); ousint := INT_TO_USINT(iint); oulint := INT_TO_ULINT(iint); ouint := INT_TO_UINT(iint); oudint := INT_TO_UDINT(iint); osint := INT_TO_SINT(iint); oreal := INT_TO_REAL(iint); olword := INT_TO_LWORD(iint); olreal := INT_TO_LREAL(iint); olint := INT_TO_LINT(iint); odword := INT_TO_DWORD(iint); odint := INT_TO_DINT(iint); obyte := INT_TO_BYTE(iint); obool := INT_TO_BOOL(iint); _GEB_ASSERT_EQFLOAT_(oreal,REAL#12816.0); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#12816.0); _GEB_ASSERT_(oword = WORD#16#3210); _GEB_ASSERT_(ousint = USINT#16); _GEB_ASSERT_(oulint = ULINT#12816); _GEB_ASSERT_(ouint = UINT#12816); _GEB_ASSERT_(oudint = UDINT#12816); _GEB_ASSERT_(osint = SINT#16); _GEB_ASSERT_(olword = LWORD#16#3210); _GEB_ASSERT_(olint = LINT#12816); _GEB_ASSERT_(odword = DWORD#16#3210); _GEB_ASSERT_(odint = DINT#12816); _GEB_ASSERT_(obyte = 16#10); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from LINT======= oword := LINT_TO_WORD(ilint); ousint := LINT_TO_USINT(ilint); oulint := LINT_TO_ULINT(ilint); ouint := LINT_TO_UINT(ilint); oudint := LINT_TO_UDINT(ilint); osint := LINT_TO_SINT(ilint); oreal := LINT_TO_REAL(ilint); olword := LINT_TO_LWORD(ilint); olreal := LINT_TO_LREAL(ilint); oint := LINT_TO_INT(ilint); odword := LINT_TO_DWORD(ilint); odint := LINT_TO_DINT(ilint); obyte := LINT_TO_BYTE(ilint); obool := LINT_TO_BOOL(ilint); _GEB_ASSERT_EQFLOAT_(oreal,REAL#1.6888e+14); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#1.688800993E14); _GEB_ASSERT_(oword = WORD#16#3210); _GEB_ASSERT_(ousint = USINT#16); _GEB_ASSERT_(oulint = ULINT#168880099308048); _GEB_ASSERT_(ouint = UINT#12816); _GEB_ASSERT_(oudint = UDINT#1985229328); _GEB_ASSERT_(osint = SINT#16); _GEB_ASSERT_(olword = LWORD#16#999876543210); _GEB_ASSERT_(oint = INT#12816); _GEB_ASSERT_(odword = DWORD#16#76543210); _GEB_ASSERT_(odint = DINT#1985229328); _GEB_ASSERT_(obyte = 16#10); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from LREAL======= oword := LREAL_TO_WORD(ilreal); ousint := LREAL_TO_USINT(ilreal); oulint := LREAL_TO_ULINT(ilreal); ouint := LREAL_TO_UINT(ilreal); oudint := LREAL_TO_UDINT(ilreal); osint := LREAL_TO_SINT(ilreal); oreal := LREAL_TO_REAL(ilreal); olword := LREAL_TO_LWORD(ilreal); olint := LREAL_TO_LINT(ilreal); oint := LREAL_TO_INT(ilreal); odword := LREAL_TO_DWORD(ilreal); odint := LREAL_TO_DINT(ilreal); obyte := LREAL_TO_BYTE(ilreal); obool := LREAL_TO_BOOL(ilreal); _GEB_ASSERT_EQFLOAT_(oreal,REAL#124.75183); _GEB_ASSERT_(oword = WORD#16#7d); _GEB_ASSERT_(ousint = USINT#125); _GEB_ASSERT_(oulint = ULINT#125); _GEB_ASSERT_(ouint = UINT#125); _GEB_ASSERT_(oudint = UDINT#125); _GEB_ASSERT_(osint = USINT#125); _GEB_ASSERT_(olword = LWORD#16#7d); _GEB_ASSERT_(olint = LINT#125); _GEB_ASSERT_(oint = INT#125); _GEB_ASSERT_(odword = DWORD#16#7d); _GEB_ASSERT_(odint = DINT#125); _GEB_ASSERT_(obyte = 16#7d); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from LWORD======= oword := LWORD_TO_WORD(ilword); ousint := LWORD_TO_USINT(ilword); oulint := LWORD_TO_ULINT(ilword); ouint := LWORD_TO_UINT(ilword); oudint := LWORD_TO_UDINT(ilword); osint := LWORD_TO_SINT(ilword); oreal := LWORD_TO_REAL(ilword); olreal := LWORD_TO_LREAL(ilword); olint := LWORD_TO_LINT(ilword); oint := LWORD_TO_INT(ilword); odword := LWORD_TO_DWORD(ilword); odint := LWORD_TO_DINT(ilword); obyte := LWORD_TO_BYTE(ilword); obool := LWORD_TO_BOOL(ilword); _GEB_ASSERT_EQFLOAT_(oreal,REAL#1.6888e+14); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#1.6888009930E14); _GEB_ASSERT_(oword = WORD#16#3210); _GEB_ASSERT_(ousint = USINT#16); _GEB_ASSERT_(oulint = ULINT#168880099308048); _GEB_ASSERT_(ouint = UINT#12816); _GEB_ASSERT_(oudint = UDINT#1985229328); _GEB_ASSERT_(osint = SINT#16); _GEB_ASSERT_(olint = LINT#168880099308048); _GEB_ASSERT_(oint = INT#168880099308048); _GEB_ASSERT_(odword = DWORD#1985229328); _GEB_ASSERT_(odint = DINT#1985229328); _GEB_ASSERT_(obyte = 16#10); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from REAL======= oword := REAL_TO_WORD(ireal); ousint := REAL_TO_USINT(ireal); oulint := REAL_TO_ULINT(ireal); ouint := REAL_TO_UINT(ireal); oudint := REAL_TO_UDINT(ireal); osint := REAL_TO_SINT(ireal); olword := REAL_TO_LWORD(ireal); olreal := REAL_TO_LREAL(ireal); olint := REAL_TO_LINT(ireal); oint := REAL_TO_INT(ireal); odword := REAL_TO_DWORD(ireal); odint := REAL_TO_DINT(ireal); obyte := REAL_TO_BYTE(ireal); obool := REAL_TO_BOOL(ireal); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#123.75); _GEB_ASSERT_(oword = WORD#16#7c); _GEB_ASSERT_(ousint = USINT#124); _GEB_ASSERT_(oulint = ULINT#124); _GEB_ASSERT_(ouint = UINT#124); _GEB_ASSERT_(oudint = UDINT#124); _GEB_ASSERT_(osint = SINT#124); _GEB_ASSERT_(olword = LWORD#16#7c); _GEB_ASSERT_(olint = LINT#124); _GEB_ASSERT_(oint = INT#124); _GEB_ASSERT_(odword = DWORD#16#7c); _GEB_ASSERT_(odint = DINT#124); _GEB_ASSERT_(obyte = 16#7c); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from SINT======= oword := SINT_TO_WORD(isint); ousint := SINT_TO_USINT(isint); oulint := SINT_TO_ULINT(isint); ouint := SINT_TO_UINT(isint); oudint := SINT_TO_UDINT(isint); oreal := SINT_TO_REAL(isint); olword := SINT_TO_LWORD(isint); olreal := SINT_TO_LREAL(isint); olint := SINT_TO_LINT(isint); oint := SINT_TO_INT(isint); odword := SINT_TO_DWORD(isint); odint := SINT_TO_DINT(isint); obyte := SINT_TO_BYTE(isint); obool := SINT_TO_BOOL(isint); _GEB_ASSERT_EQFLOAT_(oreal,REAL#16.0); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#16.0); _GEB_ASSERT_(oword = WORD#16#10); _GEB_ASSERT_(ousint = USINT#16); _GEB_ASSERT_(oulint = ULINT#16); _GEB_ASSERT_(ouint = UINT#16); _GEB_ASSERT_(oudint = UDINT#16); _GEB_ASSERT_(olword = LWORD#16#10); _GEB_ASSERT_(olint = LINT#16); _GEB_ASSERT_(oint = INT#16); _GEB_ASSERT_(odword = DWORD#16#10); _GEB_ASSERT_(odint = DINT#16); _GEB_ASSERT_(obyte = 16#10); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from UDINT======= oword := UDINT_TO_WORD(iudint); ousint := UDINT_TO_USINT(iudint); oulint := UDINT_TO_ULINT(iudint); ouint := UDINT_TO_UINT(iudint); osint := UDINT_TO_SINT(iudint); oreal := UDINT_TO_REAL(iudint); olword := UDINT_TO_LWORD(iudint); olreal := UDINT_TO_LREAL(iudint); olint := UDINT_TO_LINT(iudint); oint := UDINT_TO_INT(iudint); odword := UDINT_TO_DWORD(iudint); odint := UDINT_TO_DINT(iudint); obyte := UDINT_TO_BYTE(iudint); obool := UDINT_TO_BOOL(iudint); _GEB_ASSERT_EQFLOAT_(oreal,REAL#1.98523e+09); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#1.985229328e+09); _GEB_ASSERT_(oword = WORD#16#3210); _GEB_ASSERT_(ousint = USINT#16); _GEB_ASSERT_(oulint = ULINT#1985229328); _GEB_ASSERT_(ouint = UINT#12816); _GEB_ASSERT_(osint = SINT#16); _GEB_ASSERT_(olword = LWORD#16#76543210); _GEB_ASSERT_(olint = LINT#1985229328); _GEB_ASSERT_(oint = INT#12816); _GEB_ASSERT_(odword = DWORD#16#76543210); _GEB_ASSERT_(odint = DINT#1985229328); _GEB_ASSERT_(obyte = 16#10); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from UINT======= oword := UINT_TO_WORD(iuint); ousint := UINT_TO_USINT(iuint); oulint := UINT_TO_ULINT(iuint); oudint := UINT_TO_UDINT(iuint); osint := UINT_TO_SINT(iuint); oreal := UINT_TO_REAL(iuint); olword := UINT_TO_LWORD(iuint); olreal := UINT_TO_LREAL(iuint); olint := UINT_TO_LINT(iuint); oint := UINT_TO_INT(iuint); odword := UINT_TO_DWORD(iuint); odint := UINT_TO_DINT(iuint); obyte := UINT_TO_BYTE(iuint); obool := UINT_TO_BOOL(iuint); _GEB_ASSERT_EQFLOAT_(oreal,REAL#12816.0); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#12816.0); _GEB_ASSERT_(oword = WORD#16#3210); _GEB_ASSERT_(ousint = USINT#16); _GEB_ASSERT_(oulint = ULINT#12816); _GEB_ASSERT_(oudint = UDINT#12816); _GEB_ASSERT_(olword = LWORD#16#3210); _GEB_ASSERT_(olint = LINT#12816); _GEB_ASSERT_(osint = SINT#16); _GEB_ASSERT_(oint = INT#12816); _GEB_ASSERT_(odword = DWORD#16#3210); _GEB_ASSERT_(odint = DINT#12816); _GEB_ASSERT_(obyte = 16#10); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from ULINT======= oword := ULINT_TO_WORD(iulint); ousint := ULINT_TO_USINT(iulint); ouint := ULINT_TO_UINT(iulint); oudint := ULINT_TO_UDINT(iulint); osint := ULINT_TO_SINT(iulint); oreal := ULINT_TO_REAL(iulint); olword := ULINT_TO_LWORD(iulint); olreal := ULINT_TO_LREAL(iulint); olint := ULINT_TO_LINT(iulint); oint := ULINT_TO_INT(iulint); odword := ULINT_TO_DWORD(iulint); odint := ULINT_TO_DINT(iulint); obyte := ULINT_TO_BYTE(iulint); obool := ULINT_TO_BOOL(iulint); _GEB_ASSERT_EQFLOAT_(oreal,REAL#1.6888e+14); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#1.688800993E14); _GEB_ASSERT_(oword = WORD#16#3210); _GEB_ASSERT_(ousint = USINT#16); _GEB_ASSERT_(ouint = UINT#12816); _GEB_ASSERT_(osint = USINT#16); _GEB_ASSERT_(oudint = UDINT#1985229328); _GEB_ASSERT_(olword = LWORD#16#999876543210); _GEB_ASSERT_(olint = LINT#168880099308048); _GEB_ASSERT_(oint = INT#16#3210); _GEB_ASSERT_(odword = DWORD#16#76543210); _GEB_ASSERT_(odint = DINT#1985229328); _GEB_ASSERT_(obyte = 16#10); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from USINT======= oword := USINT_TO_WORD(iusint); oulint := USINT_TO_ULINT(iusint); ouint := USINT_TO_UINT(iusint); oudint := USINT_TO_UDINT(iusint); osint := USINT_TO_SINT(iusint); oreal := USINT_TO_REAL(iusint); olword := USINT_TO_LWORD(iusint); olreal := USINT_TO_LREAL(iusint); olint := USINT_TO_LINT(iusint); oint := USINT_TO_INT(iusint); odword := USINT_TO_DWORD(iusint); odint := USINT_TO_DINT(iusint); obyte := USINT_TO_BYTE(iusint); obool := USINT_TO_BOOL(iusint); _GEB_ASSERT_EQFLOAT_(oreal,REAL#16.0); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#16.0); _GEB_ASSERT_(oword = WORD#16#10); _GEB_ASSERT_(oulint = ULINT#16); _GEB_ASSERT_(ouint = UINT#16); _GEB_ASSERT_(oudint = UDINT#16); _GEB_ASSERT_(osint = SINT#16); _GEB_ASSERT_(olword = LWORD#16#10); _GEB_ASSERT_(olint = LINT#16); _GEB_ASSERT_(oint = INT#16); _GEB_ASSERT_(odword = DWORD#16#10); _GEB_ASSERT_(odint = DINT#16); _GEB_ASSERT_(obyte = 16#10); _GEB_ASSERT_(obool = BOOL#1); // ====== conversions from WORD======= ousint := WORD_TO_USINT(iword); oulint := WORD_TO_ULINT(iword); ouint := WORD_TO_UINT(iword); oudint := WORD_TO_UDINT(iword); osint := WORD_TO_SINT(iword); oreal := WORD_TO_REAL(iword); olword := WORD_TO_LWORD(iword); olreal := WORD_TO_LREAL(iword); olint := WORD_TO_LINT(iword); oint := WORD_TO_INT(iword); odword := WORD_TO_DWORD(iword); odint := WORD_TO_DINT(iword); obyte := WORD_TO_BYTE(iword); obool := WORD_TO_BOOL(iword); _GEB_ASSERT_EQFLOAT_(oreal,REAL#12816.0); _GEB_ASSERT_EQDOUBLE_(olreal,LREAL#12816.0); _GEB_ASSERT_(ousint = USINT#16); _GEB_ASSERT_(oulint = ULINT#12816); _GEB_ASSERT_(ouint = UINT#12816); _GEB_ASSERT_(oudint = UDINT#12816); _GEB_ASSERT_(osint = SINT#16); _GEB_ASSERT_(olword = LWORD#16#3210); _GEB_ASSERT_(olint = LINT#12816); _GEB_ASSERT_(oint = INT#12816); _GEB_ASSERT_(odword = DWORD#16#3210); _GEB_ASSERT_(odint = DINT#12816); _GEB_ASSERT_(obyte = 16#10); _GEB_ASSERT_(obool = BOOL#1); // ====== end ======= END_PROGRAM