# Math

## Numeric Value

### Specify Number

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn6737wUBYsCZBpqBJ%2Fblocks-math-%E2%9C%95-fig-2.png?generation=1524497177697443\&alt=media)

Use this block to specify a number you want to use in your app.

### Round

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXlBd8cxF5HLPtmwVbu%2F-MXlC9xs1pIj_wPvo8Et%2FScreen%20Shot%202021-04-08%20at%2012.18.39%20PM.png?alt=media\&token=7ff88d8b-cd1b-43d0-98d5-3f28b39af26a)

You can also round up or down a decimal figure into an integer using the **round** block

### Round to X Decimal Places

You can also round a number to a selected amount of decimal places

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXlEtDbb--Kgn2-0XSM%2F-MXlFFCEKfTOjhdR6L47%2FScreen%20Shot%202021-04-08%20at%2012.32.07%20PM.png?alt=media\&token=62c9fb6a-97fb-42b6-a97a-2aad0d4c76da)

### Irrational Numbers

There is also a block for irrational numbers like `π`

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn674sTAgeTdQ7HvAh%2Fblocks-math-%E2%9C%95-fig-5.png?generation=1524497169192997\&alt=media)

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXlBd8cxF5HLPtmwVbu%2F-MXlBuQ26W65qNQ3c8Yn%2FScreen%20Shot%202021-04-08%20at%2012.17.32%20PM.png?alt=media\&token=c8f3b6ea-af6a-4eab-97a0-d42cdf4fcecb)

## Analyze Numbers

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn67XCD_L3AU2WdTEJ%2Fblocks-math-%E2%9C%95-fig-6.png?generation=1524497183211004\&alt=media)

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXlBd8cxF5HLPtmwVbu%2F-MXlDagTbf-Q7wN_MowT%2FScreen%20Shot%202021-04-08%20at%2012.24.55%20PM.png?alt=media\&token=262af71f-caa8-46d3-80dc-e270ffc64af3)

Returns **true** or **false** based on whether the chosen condition applies to the number

## Perform Operations

### Constrain Number

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXlBd8cxF5HLPtmwVbu%2F-MXlE9OmRbw_ZLXTY1Ig%2Fimage.png?alt=media\&token=80c5b659-7400-48a5-a77c-717b7f2e6df8)

If the given number is of a lower value than the lower bound, this block will set the given number to have the value of the lower bound.

If the given number is of a higher value than the upper bound, this block will set the given number to have the value of the upper bound.

### Arithmetic

Perhaps the most often used calculation in an app is `addition` but this block also supports `subtraction`, `multiplication`, `division` and `exponential` figures

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn678xGSInEBGhVfDM%2Fblocks-math-%E2%9C%95-fig-7.png?generation=1524497176523163\&alt=media)

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXlBd8cxF5HLPtmwVbu%2F-MXlCXCY5pghiA2ev-ed%2FScreen%20Shot%202021-04-08%20at%2012.20.13%20PM.png?alt=media\&token=d04c560d-8a4b-48fb-a390-ae603e720b0b)

### Get remainder

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn67JQkfxHkuwMKzau%2Fblocks-math-%E2%9C%95-fig-9.png?generation=1524497196709677\&alt=media)

Returns the remainder when a number is divided by another number.

### Trigonometry

There are also a few more advanced calculation blocks that may be helpful including `trigonometric.`

These blocks will return a value assuming the input is given in **degrees**.

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn67CMs3OyF3bPVZXl%2Fblocks-math-%E2%9C%95-fig-4.png?generation=1524497166023254\&alt=media)

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXlBd8cxF5HLPtmwVbu%2F-MXlCnzY04KKHKCeujxi%2FScreen%20Shot%202021-04-08%20at%2012.21.27%20PM.png?alt=media\&token=29408abc-177e-4fc1-a468-3a5d1b108178)

### Logarithmic values

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn67Fs6NTVRGokU-PJ%2Fblocks-math-%E2%9C%95-fig-3.png?generation=1524497185940127\&alt=media)

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXlBd8cxF5HLPtmwVbu%2F-MXlCusUIGH2d-2ndItJ%2FScreen%20Shot%202021-04-08%20at%2012.21.56%20PM.png?alt=media\&token=554f24a6-cc03-4f0e-ae21-a70edb93fd6a)

###

## Introduce Randomness

For games and other apps, it may be important to introduce randomness into your app.

### Random Integer

Returns integer between two given integers. Is inclusive of the given integers.

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn67QOIwapnsDmPuFc%2Fblocks-math-%E2%9C%95-fig-11.png?generation=1524497158625446\&alt=media)

### Random Fraction

Returns a random fraction $$x$$ where $$0 ≤ x < 1$$

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn67QPNZ75lf3RymHi%2Fblocks-math-%E2%9C%95-fig-12.png?generation=1524497183009737\&alt=media)

### Other Ways to add Randomness to Your Project

The [Lists](https://docs.thunkable.com/snap-to-place/lists) blocks also have blocks for selecting [random items from a list of values](https://docs.thunkable.com/snap-to-place/lists#sum-min-max-averages-standard-deviation-random-item).

## See Also

The [Lists](https://docs.thunkable.com/snap-to-place/lists) blocks have a block for getting certain mathematical values from a List, including [sum min, max, averages, and standard deviation.](https://docs.thunkable.com/snap-to-place/lists#sum-min-max-averages-standard-deviation-random-item)
