# Performing math

Fixed provides overloads for the full set of mathematical operations.

When performing most mathematical operations the scale of the result is the larger scale of the two operands.

Example:

```dart
final t1 = Fixed.fromNum(1.234: scale: 3);
final t2 = Fixed.fromNum(1.0, scale: 1);

final t3 = t1 + t2; /// == 2.234, scale: 3
```

For multiplication, the resulting scale is the sum of the operands scales e.g.

```dart
final t1 = Fixed.fromNum(0.01, scale:2) * Fixed.fromNum(0.02, scale:2); 
print(t1); //  = 0.0002, scale: 4
```

If you need to change the scale of a number use Fixed.copyWith passing the required scale.

```dart
 Fixed.copyWith(Fixed.fromInt(5, scale: 2), scale: 10);
```

## Operators

The support operators are:

```
*  - multiplication
/  - division
%  - modulus
+  - addition
-  - subtraction
-  - unary minus (e.g. -1)
~/ - truncating division 
```

Example 6

```dart
final t1 = Fixed.parse('1.23'); // = 1.23
final t2 = Fixed.fromInt(100, scale: 2); // = 1.00

t1 + t2; // == 2.23
t2 - t1; // == -0.23
t1 * t2; // 1.2300
t1 / t2; // 1.23
-t1; // == -1.23
```


---

# 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://fixed.onepub.dev/performing-math.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.
