> For the complete documentation index, see [llms.txt](https://wiki.redmodding.org/redscript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.redmodding.org/redscript/language/built-in-functions/math.md).

# Math

### Integer operations

```swift
native func Max(a: Int32, b: Int32) -> Int32
native func Min(a: Int32, b: Int32) -> Int32
native func Abs(a: Int32) -> Int32
native func Clamp(v: Int32, min: Int32, max: Int32) -> Int32
func IsInRange(value: Int32, a: Int32, b: Int32) -> Bool
```

### Float operations

```swift
native func MaxF(a: Float, b: Float) -> Float
native func MinF(a: Float, b: Float) -> Float
native func AbsF(a: Float) -> Float
native func ClampF(v: Float, min: Float, max: Float) -> Float
native func RoundF(a: Float) -> Int32
func RoundMath(f: Float) -> Int32
func RoundTo(f: Float, decimal: Int32) -> Float
func IsInRange(value: Float, a: Float, b: Float) -> Bool

native func PowF(a: Float, x: Float) -> Float
native func LogF(a: Float) -> Float
native func ExpF(a: Float) -> Float
native func SqrtF(a: Float) -> Float
native func CeilF(a: Float) -> Int32
native func FloorF(a: Float) -> Int32
native func SinF(a: Float) -> Float
native func AsinF(a: Float) -> Float
native func CosF(a: Float) -> Float
native func AcosF(a: Float) -> Float
native func TanF(a: Float) -> Float
native func AtanF(a: Float, b: Float) -> Float
native func SqrF(a: Float) -> Float
native func LerpF(alpha: Float, a: Float, b: Float, opt clamp: Bool) -> Float

func Pi() -> Float
native func AngleNormalize(a: Float) -> Float
native func AngleDistance(target: Float, current: Float) -> Float
native func AngleApproach(target: Float, cur: Float, step: Float) -> Float
func LerpAngleF(alpha: Float, a: Float, b: Float) -> Float
native func Deg2Rad(deg: Float) -> Float
native func Rad2Deg(rad: Float) -> Float
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wiki.redmodding.org/redscript/language/built-in-functions/math.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
