al_ftofix(3alleg5)

al_ftofix3alleg5

Allegro 5 api

Usage

#include <allegro5/allegro.h>
al_fixed al_ftofix(double x);

Overview

Converts a floating point value to fixed point. Unlike al_itofix(3alleg5), this function clamps values which could overflow the type conversion, setting Allegro’s errno to ERANGE in the process if this happens.

Example:

al_fixed number;
number = al_itofix(-40000);
assert(al_fixfloor(number) == -32768);
number = al_itofix(64000);
assert(al_fixfloor(number) == 32767);
assert(!al_get_errno()); /* This will fail. */

Return value

Returns the value of the floating point value converted to fixed point clamping overflows (and setting Allegro’s errno).

Releases

6 releases since Debian 8 (Jessie); the text changed 5 times.

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12
  6. 13

From allegro5-doc 2:5.2.10.1+dfsg-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.