belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1

# MathUtils

``` public class MathUtils ```
``` extends Object ``` ``` ```

 java.lang.Object ↳ android.support.v4.math.MathUtils

A utility class providing functions useful for common mathematical operations.

## Summary

### Public methods

``` 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 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.

### Inherited methods From class ``` java.lang.Object ```

## Public methods

### clamp

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

This method takes a numerical value and ensures it fits in a given numerical range. If the number is smaller than the minimum required by the range, then the minimum of the range will be returned. If the number is higher than the maximum allowed by the range then the maximum of the range will be returned.

Parameters
`value` `double`: the value to be clamped.

`min` `double`: minimum resulting value.

`max` `double`: maximum resulting value.

Returns
`double` the clamped value.

### clamp

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

This method takes a numerical value and ensures it fits in a given numerical range. If the number is smaller than the minimum required by the range, then the minimum of the range will be returned. If the number is higher than the maximum allowed by the range then the maximum of the range will be returned.

Parameters
`value` `float`: the value to be clamped.

`min` `float`: minimum resulting value.

`max` `float`: maximum resulting value.

Returns
`float` the clamped value.

### clamp

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

This method takes a numerical value and ensures it fits in a given numerical range. If the number is smaller than the minimum required by the range, then the minimum of the range will be returned. If the number is higher than the maximum allowed by the range then the maximum of the range will be returned.

Parameters
`value` `int`: the value to be clamped.

`min` `int`: minimum resulting value.

`max` `int`: maximum resulting value.

Returns
`int` the clamped value.

• ## Classes

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]
{"ft_lang_label":"__label__en","ft_lang_prob":0.5552111,"math_prob":0.9495206,"size":2361,"snap":"2023-40-2023-50","text_gpt3_token_len":549,"char_repetition_ratio":0.16207042,"word_repetition_ratio":0.6556962,"special_character_ratio":0.22066921,"punctuation_ratio":0.13938053,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9926257,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-10-05T02:52:40Z\",\"WARC-Record-ID\":\"<urn:uuid:be4b7f25-79b7-47ab-89ed-2fd8a0b1af22>\",\"Content-Length\":\"1049681\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f4c197f5-984b-41e3-9143-981e3a1192e3>\",\"WARC-Concurrent-To\":\"<urn:uuid:9e68f67c-0156-49b0-a4c3-32bf9d4eba77>\",\"WARC-IP-Address\":\"172.253.63.138\",\"WARC-Target-URI\":\"https://developer.android.com/reference/android/support/v4/math/MathUtils\",\"WARC-Payload-Digest\":\"sha1:NHTDHHDN33BC7WKEDJC252DLKX5WFMZM\",\"WARC-Block-Digest\":\"sha1:BFOQBJJBUR2R6TWHBBONT5DEUFBMFSYB\",\"WARC-Truncated\":\"length\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233511717.69_warc_CC-MAIN-20231005012006-20231005042006-00126.warc.gz\"}"}