Mail Archives: djgpp/1999/03/13/20:59:07
On 13 Mar 99 at 10:55, Ishpeck wrote:
> I keep getting weird numbers whenever I use Fixed Variables.... they
> read something like .0076812 when I try to add 1. I've tried many
> converting an integer using itofix and fadd. . . but, it just won't
> cooperate. Is there something special about Fixed vars that I'm
> supposed to know?
Please read the Allegro documentation about them, it's quite
clear. To add an
integer to a fixed point number you must pass the integer
through `itofix' first.
my_fixed += itofix(1);
You said that you had already tried this; what went wrong when
you did? Please post a complete but short (no more than
fifteen lines) program that doesn't do what you think it
should, and tell us what you think it should do and what it
actually did. Here's my program, which prints what I expect it
to (i.e. `1.000000'):
#include <allegro.h>
int main (void)
{
fixed my_fixed = itofix(0);
my_fixed += itofix(1);
printf ("%f\n", fixtof(my_fixed));
return 0;
}
--
George
- Raw text -