---
title: "Type Conversion"
description: "Rules for casting and comparing types."
canonical_url: "https://www.zeyos.com/ixml/ixml-guide/data-types/type-conversion"
markdown_url: "https://www.zeyos.com/ai/guide/ixml/ixml-guide/data-types/type-conversion.md"
section: "ixml-guide"
authority: "guide"
language: "en"
source_repository: "zeyos/guide"
source_path: "docs/ixml/02-data-types/type-conversion.md"
source_revision: "cce886a8da98cd124ee3644711085bbdcf1a87ce"
---

# Type Conversion and Assignment

## Assignment Model

The way iXML assigns values depends on the type:

- **Primitive variables** (null, bool, int, float, string) are assigned **by value**. Copies are created.
- **Complex variables** (array, function, macro, class) are assigned **by reference**. Both variables point to the same data.

## Type Conversion Table

The following table shows how values behave across type inspection, comparison, and casting.

| Value | `TYPEOF` | `IF=''` | `IF!=''` | `IF='0'` | `CAST(bool)` | `CAST(int)` | `CAST(float)` | `CAST(string)` |
|---|---|---|---|---|---|---|---|---|
| `<undefined>` | `'undefined'` | true | false | false | `false` | `0` | `0` | `''` |
| `NULL` | `'null'` | true | false | false | `false` | `0` | `0` | `''` |
| `TRUE` | `'bool'` | false | true | false | `true` | `1` | `1` | `'1'` |
| `FALSE` | `'bool'` | true | false | false | `false` | `0` | `0` | `''` |
| `0` | `'int'` | false | true | true | `false` | `0` | `0` | `'0'` |
| `123` | `'int'` | false | true | false | `true` | `123` | `123` | `'123'` |
| `0.0` | `'float'` | false | true | true | `false` | `0` | `0` | `'0'` |
| `'0'` | `'string'` | false | true | true | `false` | `0` | `0` | `'0'` |
| `'abc'` | `'string'` | false | true | false | `true` | `0` | `0` | `'abc'` |
| `''` | `'string'` | true | false | false | `false` | `0` | `0` | `''` |
| `<array>` | `'array'` | false | true | false | `true` | `0` | `0` | `'[array#N]'` |

:::warning
**Numeric Comparison Trap**: `<if value1="0" func="=" value2="0.0">` is true because numeric comparison is performed when both sides look numeric.
:::
