Fixed Point Library...
Displaying 1-2 of 2 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Omni

No clue if this will be useful to anyone...

Fixed Point Tools

Pretty simple, instructions are in the VC file, and it's got a lot of useful links to some forum posts on Fixed Point, that piece on trig functions, and links to V3 documentation. If you don't feel like testing it, there is some good reading in the VC file. ...I was a little too lazy, so I didn't make this an actual package or anything. Which, it probably doesn't need to be a full package.

int FIX_myvar1;


FIX_myvar1 = oF_Float2Fixed('2.5');
FIX_myvar1 = FIX_myvar1 + oF_Whole2Fixed(100); //Add 100.0

Log(LStrFixed(FIX_myvar1)); //log it.
PrintString(0, 0, screen, font, oF_Fixed2Str(FIX_myvar1, 4)); //display myvar1 with 4 decimal points of detail

FIX_myvar1 = FIX_myvar1 * 8; //Multiply it by 8

FIX_myvar1 = oF_multiFF(FIX_myvar1, oF_Float2Fixed('0.5')); //Multiply it by 0.5...

SetPixel(oF_Fixed2Int(FIX_myvar1), oF_Fixed2Int(FIX_myvar1), RGB(0, 0, 0)); //Convert myvar1 to integer; supports rounding


This probably doesn't really need explaining, but it can be good for conditionals too.

int FIX_v1 = oF_Float2Fixed('1.756');


if (FIX_v1 % FIXED_SCALE == oF_Float2Fixed('0.5')) { //If the decimal part of the number is equal to 0.5, say so.
Log('Halfway!');
}

while (FIX_v1 % FIXED_SCALE < oF_Float2Fixed('0.9') { //While the decimal part of the number is less than 0.9...
FIX_v1++; //Increment.
}

Posted on 2005-01-29 18:32:04 (last edited on 2005-01-30 09:58:23)

Omni

Minor update at my webpage that repairs the Fixed2Str() function, which had some accuracy issues. I still can't update files here, as far as I know, so I'll just put it at my webpage.

Posted on 2005-01-30 09:49:25 (last edited on 2005-01-30 09:49:45)


Displaying 1-2 of 2 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.