Main Page   Modules   File List   Globals  

math.c File Reference

Math. More...


Functions

int caca_rand (int min, int max)
 Generate a random integer within a range.

unsigned int caca_sqrt (unsigned int a)
 Approximate a square root, using Newton's method to avoid costly floating point calculations.


Detailed Description

Version:
$Id: math.c 195 2003-12-31 14:21:08Z sam $
Author:
Sam Hocevar <sam@zoy.org> This file contains simple mathematical routines.

Function Documentation

int caca_rand int    min,
int    max
 

Parameters:
min  The lower bound of the integer range.
max  The upper bound of the integer range.
Returns:
A random integer comprised between min and max, inclusive.

unsigned int caca_sqrt unsigned int    a
 

Parameters:
a  A positive integer.
Returns:
The approximate square root of a.