SDL School

API reference / Math

SDL_sqrtf

Function, SDL3

Gives the square root of a number.

Declaration

#include <SDL3/SDL.h>

float SDL_sqrtf(float x);

Parameters

xThe number. It must not be negative.

Return value

The square root.

Example

Draw shapes
float half_width = SDL_sqrtf(radius * radius - dy * dy);

See this code run in Draw shapes. Download the full program (.zip)

In SDL2

The name is the same.