PandA-2024.02
Macros | Typedefs | Functions
fixedptc.h File Reference
#include <stdint.h>
Include dependency graph for fixedptc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FIXEDPT_BITS   32
 
#define FIXEDPT_WBITS   16
 
#define FIXEDPT_VCSID   "$Id$"
 
#define FIXEDPT_FBITS   (FIXEDPT_BITS - FIXEDPT_WBITS)
 
#define FIXEDPT_FMASK   (((fixedpt)1 << FIXEDPT_FBITS) - 1)
 
#define fixedpt_rconst(R)   ((fixedpt)((R) * FIXEDPT_ONE + ((R) >= 0 ? 0.5 : -0.5)))
 
#define fixedpt_fromint(I)   ((fixedptd)(I) << FIXEDPT_FBITS)
 
#define fixedpt_toint(F)   ((F) >> FIXEDPT_FBITS)
 
#define fixedpt_add(A, B)   ((A) + (B))
 
#define fixedpt_sub(A, B)   ((A) - (B))
 
#define fixedpt_xmul(A, B)   ((fixedpt)(((fixedptd)(A) * (fixedptd)(B)) >> FIXEDPT_FBITS))
 
#define fixedpt_xdiv(A, B)   ((fixedpt)(((fixedptd)(A) << FIXEDPT_FBITS) / (fixedptd)(B)))
 
#define fixedpt_fracpart(A)   ((fixedpt)(A) & FIXEDPT_FMASK)
 
#define FIXEDPT_ONE   ((fixedpt)((fixedpt)1 << FIXEDPT_FBITS))
 
#define FIXEDPT_ONE_HALF   (FIXEDPT_ONE >> 1)
 
#define FIXEDPT_TWO   (FIXEDPT_ONE + FIXEDPT_ONE)
 
#define FIXEDPT_PI   fixedpt_rconst(3.14159265358979323846)
 
#define FIXEDPT_TWO_PI   fixedpt_rconst(2 * 3.14159265358979323846)
 
#define FIXEDPT_HALF_PI   fixedpt_rconst(3.14159265358979323846 / 2)
 
#define FIXEDPT_E   fixedpt_rconst(2.7182818284590452354)
 
#define fixedpt_abs(A)   ((A) < 0 ? -(A) : (A))
 

Typedefs

typedef int32_t fixedpt
 
typedef int64_t fixedptd
 
typedef uint32_t fixedptu
 
typedef uint64_t fixedptud
 

Functions

fixedpt fixedpt_mul (fixedpt A, fixedpt B)
 
fixedpt fixedpt_div (fixedpt A, fixedpt B)
 
void fixedpt_str (fixedpt A, char *str, int max_dec)
 Convert the given fixedpt number to a decimal string. More...
 
char * fixedpt_cstr (const fixedpt A, const int max_dec)
 
fixedpt fixedpt_sqrt (fixedpt A)
 
fixedpt fixedpt_sin (fixedpt fp)
 
fixedpt fixedpt_cos (fixedpt A)
 
fixedpt fixedpt_tan (fixedpt A)
 
fixedpt fixedpt_exp (fixedpt fp)
 
fixedpt fixedpt_ln (fixedpt x)
 
fixedpt fixedpt_log (fixedpt x, fixedpt base)
 
fixedpt fixedpt_pow (fixedpt n, fixedpt exp)
 
fixedpt fixedpt_acos (fixedpt x)
 
void fixedpt_print (fixedpt A)
 
void fixedpt_print_file (fixedpt A)
 

Macro Definition Documentation

◆ fixedpt_abs

#define fixedpt_abs (   A)    ((A) < 0 ? -(A) : (A))

Definition at line 126 of file fixedptc.h.

◆ fixedpt_add

#define fixedpt_add (   A,
  B 
)    ((A) + (B))

Definition at line 110 of file fixedptc.h.

◆ FIXEDPT_BITS

#define FIXEDPT_BITS   32

Definition at line 75 of file fixedptc.h.

◆ FIXEDPT_E

#define FIXEDPT_E   fixedpt_rconst(2.7182818284590452354)

Definition at line 124 of file fixedptc.h.

◆ FIXEDPT_FBITS

#define FIXEDPT_FBITS   (FIXEDPT_BITS - FIXEDPT_WBITS)

Definition at line 104 of file fixedptc.h.

◆ FIXEDPT_FMASK

#define FIXEDPT_FMASK   (((fixedpt)1 << FIXEDPT_FBITS) - 1)

Definition at line 105 of file fixedptc.h.

◆ fixedpt_fracpart

#define fixedpt_fracpart (   A)    ((fixedpt)(A) & FIXEDPT_FMASK)

Definition at line 116 of file fixedptc.h.

◆ fixedpt_fromint

#define fixedpt_fromint (   I)    ((fixedptd)(I) << FIXEDPT_FBITS)

Definition at line 108 of file fixedptc.h.

◆ FIXEDPT_HALF_PI

#define FIXEDPT_HALF_PI   fixedpt_rconst(3.14159265358979323846 / 2)

Definition at line 123 of file fixedptc.h.

◆ FIXEDPT_ONE

#define FIXEDPT_ONE   ((fixedpt)((fixedpt)1 << FIXEDPT_FBITS))

Definition at line 118 of file fixedptc.h.

◆ FIXEDPT_ONE_HALF

#define FIXEDPT_ONE_HALF   (FIXEDPT_ONE >> 1)

Definition at line 119 of file fixedptc.h.

◆ FIXEDPT_PI

#define FIXEDPT_PI   fixedpt_rconst(3.14159265358979323846)

Definition at line 121 of file fixedptc.h.

◆ fixedpt_rconst

#define fixedpt_rconst (   R)    ((fixedpt)((R) * FIXEDPT_ONE + ((R) >= 0 ? 0.5 : -0.5)))

Definition at line 107 of file fixedptc.h.

◆ fixedpt_sub

#define fixedpt_sub (   A,
  B 
)    ((A) - (B))

Definition at line 111 of file fixedptc.h.

◆ fixedpt_toint

#define fixedpt_toint (   F)    ((F) >> FIXEDPT_FBITS)

Definition at line 109 of file fixedptc.h.

◆ FIXEDPT_TWO

#define FIXEDPT_TWO   (FIXEDPT_ONE + FIXEDPT_ONE)

Definition at line 120 of file fixedptc.h.

◆ FIXEDPT_TWO_PI

#define FIXEDPT_TWO_PI   fixedpt_rconst(2 * 3.14159265358979323846)

Definition at line 122 of file fixedptc.h.

◆ FIXEDPT_VCSID

#define FIXEDPT_VCSID   "$Id$"

Definition at line 102 of file fixedptc.h.

◆ FIXEDPT_WBITS

#define FIXEDPT_WBITS   16

Definition at line 95 of file fixedptc.h.

◆ fixedpt_xdiv

#define fixedpt_xdiv (   A,
  B 
)    ((fixedpt)(((fixedptd)(A) << FIXEDPT_FBITS) / (fixedptd)(B)))

Definition at line 114 of file fixedptc.h.

◆ fixedpt_xmul

#define fixedpt_xmul (   A,
  B 
)    ((fixedpt)(((fixedptd)(A) * (fixedptd)(B)) >> FIXEDPT_FBITS))

Definition at line 112 of file fixedptc.h.

Typedef Documentation

◆ fixedpt

typedef int32_t fixedpt

Definition at line 79 of file fixedptc.h.

◆ fixedptd

typedef int64_t fixedptd

Definition at line 80 of file fixedptc.h.

◆ fixedptu

typedef uint32_t fixedptu

Definition at line 81 of file fixedptc.h.

◆ fixedptud

typedef uint64_t fixedptud

Definition at line 82 of file fixedptc.h.

Function Documentation

◆ fixedpt_acos()

fixedpt fixedpt_acos ( fixedpt  x)

◆ fixedpt_cos()

fixedpt fixedpt_cos ( fixedpt  A)

Definition at line 162 of file fixedptc.c.

◆ fixedpt_cstr()

char* fixedpt_cstr ( const fixedpt  A,
const int  max_dec 
)

Definition at line 88 of file fixedptc.c.

◆ fixedpt_div()

fixedpt fixedpt_div ( fixedpt  A,
fixedpt  B 
)

Definition at line 17 of file fixedptc.c.

◆ fixedpt_exp()

fixedpt fixedpt_exp ( fixedpt  fp)

Definition at line 174 of file fixedptc.c.

◆ fixedpt_ln()

fixedpt fixedpt_ln ( fixedpt  x)

Definition at line 259 of file fixedptc.c.

◆ fixedpt_log()

fixedpt fixedpt_log ( fixedpt  x,
fixedpt  base 
)

Definition at line 298 of file fixedptc.c.

◆ fixedpt_mul()

fixedpt fixedpt_mul ( fixedpt  A,
fixedpt  B 
)

Definition at line 11 of file fixedptc.c.

◆ fixedpt_pow()

fixedpt fixedpt_pow ( fixedpt  n,
fixedpt  exp 
)

Definition at line 304 of file fixedptc.c.

◆ fixedpt_print()

void fixedpt_print ( fixedpt  A)

◆ fixedpt_print_file()

void fixedpt_print_file ( fixedpt  A)

◆ fixedpt_sin()

fixedpt fixedpt_sin ( fixedpt  fp)

Definition at line 130 of file fixedptc.c.

◆ fixedpt_sqrt()

fixedpt fixedpt_sqrt ( fixedpt  A)

Definition at line 96 of file fixedptc.c.

◆ fixedpt_str()

void fixedpt_str ( fixedpt  A,
char *  str,
int  max_dec 
)

Convert the given fixedpt number to a decimal string.

The max_dec argument specifies how many decimal digits to the right of the decimal point to generate. If set to -1, the "default" number of decimal digits will be used (2 for 32-bit fixedpt width, 10 for 64-bit fixedpt width); If set to -2, "all" of the digits will be returned, meaning there will be invalid, bogus digits outside the specified precisions.

Definition at line 35 of file fixedptc.c.

◆ fixedpt_tan()

fixedpt fixedpt_tan ( fixedpt  A)

Definition at line 168 of file fixedptc.c.


Generated on Mon Feb 12 2024 13:03:08 for PandA-2024.02 by doxygen 1.8.13