# Coercing Strings To Integers

When evaluating expressions, strings are automatically coerced to integers where the expression implies an integer is required and a string is supplied.
```e.g.

a1	.set	0x123
fred	.set	a1 + "0xBC00"	; automatic coercion of string to integer

.dw	fred

; is equivalent to
.dw	0xBD23

----------------------

Both operands of the == comparison operator are required to be of the
same type (either both strings or both integer). The right hand operand
is automatically coerced to be of the same type as the left operand if
it is different.

2   == 1			left and right hand operands are integers
so perform integer EQUALS comparison which
yields 0

"2" == 1			left hand operand is string and right hand
operand is integer so coerce right hand operand
to string and perform string EQUALS comparison
which yields 0

"2" == "1"			left and right hand operands are strings
so perform string EQUALS comparison which
yields 0

2   == "1"			left hand operand is integer and right hand
operand is string so coerce right hand operand
to integer and perform integer EQUALS comparison
which yields 0

```
BEWARE:
Coercion from string to integer requires that a vaild number is present at the start of the string that is to be coerced. If the string does not hold a valid number then a zero is returned. A string that contains a partly valid number at its start will have all the digits upto the first invalid digit converted to an integer.
```e.g.
"0109"				The leading 0 character indicates that the remainder of the
number is in octal (base 8), so the number is interpreted
as as the valid octal number 010 (which is 8 in decimal)
followed by the invalid octal character 9. This may lead to
some confussion initially since the returned number when
printed normally will show up as 8 which does not appear
anywhere in the original "0109" string.

```
See the description of numbers for further information on valid string to integer coercion