Previous Topic Next topic Print topic


&HEX-AS-SIGNED

Convert a text string containing hexadecimal characters to a signed 1-, 2-, or 4-byte value.
Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.

Syntax:

&HEX-AS-SIGNED (&variablename[, &targetlength])

Aliases:

&hex-as-signed (&variablename[, &targetlength])
&Hex-As-Signed (&variablename[, &targetlength])
&HEXASSIGNED (&variablename[, &targetlength])
&hexassigned (&variablename[, &targetlength])
&HexAsSigned (&variablename[, &targetlength])

Comments:

When converting hex to an equivalent binary string, &targetlength determines which bit is interpreted as a sign bit. For example,

&HEX-AS-SIGNED ("7F", 1) = 127
&HEX-AS-SIGNED ("80", 1) = -128

For hex 80 (binary 10000000), the eighth bit from the right (counting the rightmost bit as 1) is the sign bit, but

&HEX-AS-SIGNED ("7F", 2) = 127
&HEX-AS-SIGNED ("80", 2) = 256

For hex 80 (binary 0000000010000000), the 16th bit from the right is the sign bit.

Example:

&HEX-AS-SIGNED ("00")  = 0
&HEX-AS-SIGNED ("01")  = 1
&HEX-AS-SIGNED ("0A")  = 10
&HEX-AS-SIGNED ("0F")  = 15
&HEX-AS-SIGNED ("10")  = 16
&HEX-AS-SIGNED ("13")  = 19
&HEX-AS-SIGNED ("6F")  = 111
&HEX-AS-SIGNED ("7F")  = 127
&HEX-AS-SIGNED ("80")  = 128
&HEX-AS-SIGNED ("FF")  = 255
&HEX-AS-SIGNED ("F")   = 15
&HEX-AS-SIGNED ("00", 1) = 0
&HEX-AS-SIGNED ("01", 1) = 1
&HEX-AS-SIGNED ("0A", 1) = 10
&HEX-AS-SIGNED ("0F", 1) = 15
&HEX-AS-SIGNED ("10", 1) = 16
&HEX-AS-SIGNED ("13", 1) = 19
&HEX-AS-SIGNED ("6F", 1) = 111
&HEX-AS-SIGNED ("7F", 1) = 127
&HEX-AS-SIGNED ("80", 1) = -128
&HEX-AS-SIGNED ("FF", 1) = -1
&HEX-AS-SIGNED ("FF", "1") = 255
&HEX-AS-SIGNED ("FF", 3) = 255
&HEX-AS-SIGNED ("1000")  = 4096
&HEX-AS-SIGNED ("4142")  = 16962
&HEX-AS-SIGNED ("6FFF")  = 28671
&HEX-AS-SIGNED ("7000")  = 28672
&HEX-AS-SIGNED ("7FFF")  = 32767
&HEX-AS-SIGNED ("8000")  = 32768
&HEX-AS-SIGNED ("FFFF")  = 65535
&HEX-AS-SIGNED ("1000", 2) = 4096
&HEX-AS-SIGNED ("4142", 2) = 16962
&HEX-AS-SIGNED ("6FFF", 2) = 28671
&HEX-AS-SIGNED ("7000", 2) = 28672
&HEX-AS-SIGNED ("7FFF", 2) = 32767
&HEX-AS-SIGNED ("8000", 2) = -32768
&HEX-AS-SIGNED ("FFFF", 2) = -1
&HEX-AS-SIGNED ("100000")    = 1048576
&HEX-AS-SIGNED ("10000000")  = 268435456
&HEX-AS-SIGNED ("7FFFFFFF")  = 2147483647
&HEX-AS-SIGNED ("80000000")  = -2147483648
&HEX-AS-SIGNED ("FFFFFFFF")  = -1
Previous Topic Next topic Print topic