---
title: "Math"
canonical_url: https://developer.repebble.com/docs/c/Standard_C/Math/
last_updated: 2026-10-29
sdk_version: 4.33.1
---
# Math

Source: https://developer.repebble.com/docs/c/Standard_C/Math/

Standard math functions.

## Function Documentation

int rand()

Generate a pseudo-random integer between 0 and [RAND\_MAX](https://developer.repebble.com/docs/c/Standard_C/Math.md#RAND_MAX) inclusive.

This function can be seeded by [srand()](https://developer.repebble.com/docs/c/Standard_C/Math.md#srand).

A simple way to change the range to be an integer between 0 and n-1 inclusive is using % e.g. `rand() % n`.

#### Returns

The pseudo-randomly generated number

void srand(unsigned int seed)

Seed the pseudo-random number generator.

When your app starts, the pseudo-random number generator is automatically seeded with a random number that is generated by a high-entropy hardware random number generator.

This function affects subsequent calls to [rand()](https://developer.repebble.com/docs/c/Standard_C/Math.md#rand) to produce a sequence of numbers for a given seed value. You can use this to either create a different sequence of numbers by always using a different seed or to obtain the same sequence of numbers by reusing the same seed.

#### Parameters
 seed

The source number used to generate a sequence of pseudo-random numbers

## Macro Definition Documentation

#define RAND\_MAX  

The maximum integer value [rand()](https://developer.repebble.com/docs/c/Standard_C/Math.md#rand) may return.
