FS2_Open Open source remastering of the Freespace 2 engine
floating.h File Reference
`#include <math.h>`
`#include <float.h>`
`#include "globalincs/pstypes.h"`

Go to the source code of this file.

## Macros

#define fl_is_nan(fl)   _isnan((double)(fl))

#define fl_sqrt(fl)   sqrtf(fl)

#define fl_isqrt(fl)   (1.0f/sqrtf(fl))

#define fl_abs(fl)   fabsf(fl)

#define i2fl(i)   ((float)(i))

#define fl2i(fl)   ((int)(fl))

#define fl2ir(fl)   ((int)(fl + ((fl < 0.0f) ? -0.5f : 0.5f)))

#define flceil(fl)   (int)ceil(fl)

#define flfloor(fl)   (int)floor(fl)

#define f2fl(fx)   ((float)(fx)/65536.0f)

#define fl2f(fl)   (int)((fl)*65536.0f)

#define fl_tan(fl)   tanf(fl)

#define fl_radians(fl)   ((float)((fl) * (PI / 180.0f)))

#define fl_degrees(fl)   ((float)((fl) * (180.0f / PI)))

## Functions

float frand ()
Return random value in range 0.0..1.0- (1.0- means the closest number less than 1.0) More...

int rand_chance (float frametime, float chance=1.0f)
Call this in the frame interval to get TRUE chance times per second. More...

float frand_range (float min, float max)
Return a floating point number in the range min..max. More...

bool fl_equal (float a, float b)

float fl_roundoff (float x, int multiple)
Rounds off a floating point number to a multiple of some number. More...

## Macro Definition Documentation

 #define f2fl ( fx ) ((float)(fx)/65536.0f)

Definition at line 37 of file floating.h.

 #define fl2f ( fl ) (int)((fl)*65536.0f)

Definition at line 38 of file floating.h.

 #define fl2i ( fl ) ((int)(fl))

Definition at line 33 of file floating.h.

 #define fl2ir ( fl ) ((int)(fl + ((fl < 0.0f) ? -0.5f : 0.5f)))

Definition at line 34 of file floating.h.

 #define fl_abs ( fl ) fabsf(fl)

Definition at line 31 of file floating.h.

 #define fl_degrees ( fl ) ((float)((fl) * (180.0f / PI)))

Definition at line 45 of file floating.h.

 #define fl_is_nan ( fl ) _isnan((double)(fl))

Definition at line 25 of file floating.h.

 #define fl_isqrt ( fl ) (1.0f/sqrtf(fl))

Definition at line 30 of file floating.h.

 #define fl_radians ( fl ) ((float)((fl) * (PI / 180.0f)))

Definition at line 42 of file floating.h.

 #define fl_sqrt ( fl ) sqrtf(fl)

Definition at line 29 of file floating.h.

 #define fl_tan ( fl ) tanf(fl)

Definition at line 39 of file floating.h.

 #define flceil ( fl ) (int)ceil(fl)

Definition at line 35 of file floating.h.

 #define flfloor ( fl ) (int)floor(fl)

Definition at line 36 of file floating.h.

 #define i2fl ( i ) ((float)(i))

Definition at line 32 of file floating.h.

## Function Documentation

 bool fl_equal ( float a, float b )
inline

Definition at line 94 of file floating.h.

 float fl_roundoff ( float x, int multiple )

Rounds off a floating point number to a multiple of some number.

Parameters
 x Input floating point number multiple Multiple to round to

Definition at line 21 of file floating.cpp.

 float frand ( )

Return random value in range 0.0..1.0- (1.0- means the closest number less than 1.0)

Definition at line 35 of file floating.cpp.

 float frand_range ( float min, float max )

Return a floating point number in the range min..max.

Parameters
 min Minimum (inclusive) max Maxiumum (inclusive)

Definition at line 50 of file floating.cpp.

 int rand_chance ( float frametime, float chance )

Call this in the frame interval to get TRUE chance times per second.

If you want it to return TRUE 3 times per second, call it in the frame interval like so: rand_chance(flFrametime, 3.0f);

Parameters
 frametime chance

Definition at line 66 of file floating.cpp.