MathUtils

public class MathUtils
extends Object

java.lang.Object
   ↳ androidx.core.math.MathUtils


A utility class providing functions useful for common mathematical operations.

Summary

Public methods

static long addExact(long x, long y)

See Math.addExact(long, long).

static int addExact(int x, int y)

See Math.addExact(int, int).

static double clamp(double value, double min, double max)

This method takes a numerical value and ensures it fits in a given numerical range.

static long clamp(long value, long min, long max)

This method takes a numerical value and ensures it fits in a given numerical range.

static float clamp(float value, float min, float max)

This method takes a numerical value and ensures it fits in a given numerical range.

static int clamp(int value, int min, int max)

This method takes a numerical value and ensures it fits in a given numerical range.

static long decrementExact(long a)

See Math.decrementExact(long).

static int decrementExact(int a)

See Math.decrementExact(int).

static long incrementExact(long a)

See Math.incrementExact(long).

static int incrementExact(int a)

See Math.incrementExact(int).

static long multiplyExact(long x, long y)

See Math.multiplyExact(long, long).

static int multiplyExact(int x, int y)

See Math.multiplyExact(int, int).

static int negateExact(int a)

See Math.negateExact(int).

static long negateExact(long a)

See Math.negateExact(long).

static long subtractExact(long x, long y)

See Math.subtractExact(long, long).

static int subtractExact(int x, int y)

See