fixtoi(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– fixtoi β€” from the Allegro manual, bestie edition πŸ’–

okay so this is fixtoi(3), straight out of the Allegro game programming library, and she's here to turn your fixed point numbers into regular integers. with rounding. slay.


✨ NAME ✨

fixtoi β€” converts a fixed point to integer with rounding. it lives in the Allegro game programming library, and yes she is that girl πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

int fixtoi(fixed x);

like, that's it. one function. one argument. iconic behavior honestly.


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: fixtoi takes your fixed point value and hands you back an integer, rounding as required to the nearest integer. no cap, that's the whole job and she does it beautifully ✨

here's the example, and no I did not touch a single character of it because I respect the craft:

int result;
/* This will put 33 into `result'. */
result = fixtoi(itofix(100) / 3);
/* But this will round up to 17. */
result = fixtoi(itofix(100) / 6);

see how the second one rounds up? the way that 100 / 6 does NOT give you 16... she said "we're going up to 17 bestie" and honestly? correct. main character energy fr fr πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘

your little reading list, go off:


🫢 reminder bestie: this whole page is from Allegro version 4.4.3, and the page itself is fixtoi(3). that's the sign-off, mwah πŸ’–πŸŽ€πŸ¦‹βœ¨
πŸ“¦ where this page comes from