Google is committed to advancing racial equity for Black communities. See how.

# DpSquared

@Immutable inline class DpSquared : Comparable<DpSquared>
 kotlin.Any ↳ androidx.compose.ui.unit.DpSquared

Holds a unit of squared dimensions, such as 1.value * 2.dp. DpSquared, DpCubed, and DpInverse are used primarily for Dp calculations to ensure resulting units are as expected. Many times, Dp calculations use scalars to determine the final dimension during calculation: val width = oldWidth * stretchAmount Other times, it is useful to do intermediate calculations with Dimensions directly: val width = oldWidth * newTotalWidth / oldTotalWidth

## Summary

Public constructors
<init>(value: Float)

Holds a unit of squared dimensions, such as 1.value * 2.dp.

Public methods
operator Int

Support comparing DpSquared with comparison operators.

operator DpSquared
div(other: Float)

Divide a DimensionSquare by a scalar.

operator Dp
div(other: Dp)

Divide by a Dp to get a Dp result.

operator Float
div(other: DpSquared)

Divide by a DpSquared to get a scalar result.

operator DpInverse
div(other: DpCubed)

Divide by a DpCubed to get a DpInverse result.

operator DpSquared
minus(other: DpSquared)

Subtract a DimensionSquare from another one.

operator DpSquared
plus(other: DpSquared)

operator DpSquared
times(other: Float)

Multiply by a scalar to get a DpSquared result.

operator DpCubed
times(other: Dp)

Multiply by a scalar to get a DpSquared result.

String

Inherited extension functions
From androidx.core.util
 infix Range T.rangeTo(that: T) Creates a range from this Comparable value to that.
Properties
Float

## Public constructors

### <init>

DpSquared(value: Float)

Holds a unit of squared dimensions, such as 1.value * 2.dp. DpSquared, DpCubed, and DpInverse are used primarily for Dp calculations to ensure resulting units are as expected. Many times, Dp calculations use scalars to determine the final dimension during calculation: val width = oldWidth * stretchAmount Other times, it is useful to do intermediate calculations with Dimensions directly: val width = oldWidth * newTotalWidth / oldTotalWidth

## Public methods

### compareTo

@Stable operator fun compareTo(other: DpSquared): Int

Support comparing DpSquared with comparison operators.

### div

@Stable inline operator fun div(other: Float): DpSquared

Divide a DimensionSquare by a scalar.

### div

@Stable inline operator fun div(other: Dp): Dp

Divide by a Dp to get a Dp result.

### div

@Stable inline operator fun div(other: DpSquared): Float

Divide by a DpSquared to get a scalar result.

### div

@Stable inline operator fun div(other: DpCubed): DpInverse

Divide by a DpCubed to get a DpInverse result.

### minus

@Stable inline operator fun minus(other: DpSquared): DpSquared

Subtract a DimensionSquare from another one.

### plus

@Stable inline operator fun plus(other: DpSquared): DpSquared

### times

@Stable inline operator fun times(other: Float): DpSquared

Multiply by a scalar to get a DpSquared result.

### times

@Stable inline operator fun times(other: Dp): DpCubed

Multiply by a scalar to get a DpSquared result.

### toString

@Stable fun toString(): String

val value: Float