---
name: "linearConversion"
type: command
status: ok
groups: ["Math"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/linearConversion
revid: 364172
updated: 2024-05-05T10:46:44Z
---

# linearConversion

*Command · Math · Arma 3 v0.50*

## Description

Converts given value from given "from" range to wanted "to" range. If clipping is set to [true](../commands/true.md), the resulting value is guaranteed to be within "to" range no matter what. 

> [!NOTE]
> **Arma 3:** Faster alternative to [BIS_fnc_linearConversion](../functions/BIS_fnc_linearConversion.md).

## Syntax

```sqf
linearConversion [minFrom, maxFrom, value, minTo, maxTo, clip]
```

**Parameters:**

- `minFrom`: [Number](../topics/Number.md) - start "from" range
- `maxFrom`: [Number](../topics/Number.md) - end "from" range
- `value`: [Number](../topics/Number.md) - given value from "from" range
- `minTo`: [Number](../topics/Number.md) - start "to" range
- `maxTo`: [Number](../topics/Number.md) - end "to" range
- `clip`: [Boolean](../topics/Boolean.md) - (Optional, default [false](../commands/false.md)) if [true](../commands/true.md), resulting value cannot leave "to" range

**Returns:** [Number](../topics/Number.md) - respectful value from "to" range

## Examples

### Example 1

```sqf
// Say given range is 0 to 1 and wanted range is 0 to 100 (percent calculation). Given value 0.55 then will be 55
linearConversion [0, 1, 0.55, 0, 100];

// but if given value is 1.1 it will return 110
linearConversion [0, 1, 1.1, 0, 100, false];

// or if clipping is true it will return 100
linearConversion [0, 1, 1.1, 0, 100, true];
```

### Example 2

```sqf
linearConversion [4, 8, 5, 0, 1, false];
```

### Example 3

```sqf
// Calculate days from 1/1/1970
fnc_daysFromEpoc = 
{
    private _year = param [0];
    private _days = 0;
    for "_i" from 1970 to _year - 1 do 
    {
        _days = _days + round linearConversion [0, 1, dateToNumber [_i, 12, 31, 23, 59], 0, 365, false];
    };
    _days + linearConversion [0, 1, dateToNumber _this, 0, 365, false];
};

hint str (date call fnc_daysFromEpoc);
```

## See also

[round](../commands/round.md) · [floor](../commands/floor.md) · [ceil](../commands/ceil.md) · [vectorLinearConversion](../commands/vectorLinearConversion.md) · [bezierInterpolation](../commands/bezierInterpolation.md)

<sub>Source: [BI Community Wiki — linearConversion](https://community.bistudio.com/wiki/linearConversion) (revision 364172).</sub>
