# Expressions

In the IDC expressions you can use almost all C operations except:

```
  complex assignment operations as '+='
```

[Constants](https://github.com/HexRaysSA/docs/blob/main/developer-guide/idc/core-concepts/1582.md) are defined more or less like in C, with some minor differences.

There are four type conversion operations:

```
  long(expr)  floating point numbers are truncated during conversion
  char(expr)
  float(expr)
  __int64(expr)
```

However, explicit type conversions are rarely required because all type conversions are made automatically:

```
  - addition:
        if both operands are strings,
          string addition is performed (strings are concatenated);
        if both operands are objects,
          object combination is performed (a new object is created)
        if floating point operand exists,
          both operands are converted to floats;
        otherwise
          both operands are converted to longs;

  - subtraction/multiplication/division:
        if floating point operand exists,
          both operands are converted to floats;
        if both operands are objects and the operation is subtraction,
          object subtraction is performed (a new object is created)
        otherwise
          both operands are converted to longs;

  - comparisons (==,!=, etc):
        if both operands are strings, string comparison is performed;
        if floating point operand exists,
          both operands are converted to floats;
        otherwise
          both operands are converted to numbers;

  - all other operations:
        operand(s) are converted to longs;
```

If any of the long operands is 64bit, the other operand is converted to 64bit too.

There is one notable exception concerning type conversions: if one operand is a string and the other is zero (0), then a string operation is performed. Zero is converted to an empty string in this case.

The & operator is used to take a reference to a variable. References themselves cannot be modified once created. Any assignment to them will modify the target variable. For example:

```
        auto x, r;
        r = &x;
        r = 1;   // x is equal to 1 now
```

References to references are immediately resolved:

```
        auto x, r1, r2;
        r1 = &x;
        r2 = &r1; // r2 points to x
```

Since all non-object arguments are passed to functions by value, references are a good way to pass arguments by reference.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hex-rays.com/9.0/developer-guide/idc/core-concepts/expressions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
