---
title: UnitConverterLinear
framework: foundation
role: symbol
role_heading: Class
path: foundation/unitconverterlinear
---

# UnitConverterLinear

A description of how to convert between units using a linear equation.

## Declaration

```swift
class UnitConverterLinear
```

## Overview

Overview A linear equation for unit conversion takes the form y = mx + b, such that the following is true: y is the value in terms of the base unit of the dimension. m is the known coefficient to use for this unit’s conversion. x is the value in terms of the unit on which you call this method. b is the known constant to use for this unit’s conversion. The baseUnitValueFromValue: method performs the conversion in the form of y = mx + b, where x represents the value passed in and y represents the value returned. The valueFromBaseUnitValue: method performs the inverse conversion in the form of x = (y - b) / m, where y represents the value passed in and x represents the value returned. For example, consider the fahrenheit unit that UnitTemperature defines. The baseUnitValue(fromValue:) method calculates the value in the base unit, kelvin, using the formula K = (0.55555555555556) × °F + 255.37222222222427. The value(fromBaseUnitValue:) method calculates the value in fahrenheit using the formula °F = (K — 255.37222222222427) / (0.55555555555556), where the coefficient is (0.55555555555556) and the constant is 255.37222222222427. Units that perform conversion using only a scale factor have a coefficient equal to the scale factor and a constant equal to 0. For example, consider the kilometers unit UnitLength defines. The baseUnitValue(fromValue:) method calculates the value in meters using the formula valueInMeters = 1000 * valueInKilometers + 0. The value(fromBaseUnitValue:) calculates the value in kilometers using the formula valueInKilometers = (valueInMeters - 0) / 1000, where the coefficient is 1000 and the constant is 0.

## Topics

### Accessing Linear Parameters

- [coefficient](foundation/unitconverterlinear/coefficient.md)
- [constant](foundation/unitconverterlinear/constant.md)

### Creating Unit Converters

- [init(coefficient:)](foundation/unitconverterlinear/init(coefficient:).md)
- [init(coefficient:constant:)](foundation/unitconverterlinear/init(coefficient:constant:).md)

### Initializers

- [init(coder:)](foundation/unitconverterlinear/init(coder:).md)

## Relationships

### Inherits From

- [UnitConverter](foundation/unitconverter.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Conversion

- [UnitConverter](foundation/unitconverter.md)
