fixdiv(3alleg)

fixdiv3alleg

Fixed point division. allegro game programming library.

Usage

#include <allegro.h>

fixed fixdiv(fixed x, fixed y);

Overview

A fixed point value can be divided by an integer with the normal `/' operator. To divide two fixed point values, though, you must use this function. If a division by zero occurs, `errno' will be set and the maximum possible value will be returned, but `errno' is not cleared if the operation is successful. This means that if you are going to test for division by zero you should set `errno=0' before calling fixdiv(). Example:

   fixed result;
   /* This will put 0.06060 `result'. */
   result = fixdiv(itofix(2), itofix(33));
   /* This will put 0 into `result'. */
   result = fixdiv(0, itofix(-30));
   /* Sets `errno' and puts -32768 into `result'. */
   result = fixdiv(itofix(-100), itofix(0));
   ASSERT(!errno); /* This will fail. */

Return value

Returns the result of dividing `x' by `y'. If `y' is zero, returns the maximum possible fixed point value and sets `errno' to ERANGE.

Releases

4 releases since Debian 3.1 (Sarge); the text changed 2 times.

  1. 3.1
  2. 4.0
  3. 5.0–6.0

From liballegro-doc 2:4.2.2-2.2 in Debian 6.0 (Squeeze). Parsed by carta from the page's man source.