UCT local_tree_eval=total: Introduce
[pachi/nmclean.git] / fixp.h
blob40d35a20fa1a7c2c62dfda1c2c6560c64f086c87
1 #ifndef PACHI_FIXP_H
2 #define PACHI_FIXP_H
4 /* Tools for counting fixed-point numbers. */
6 /* We implement a simple fixed-point number type, with fixed number of
7 * fractional binary digits after the radix point. */
9 #include <stdint.h>
11 typedef uint_fast32_t fixp_t;
13 /* We should accomodate at least 0..131072 (17bits) in the whole number
14 * portion; assuming at least 32bit integer, that leaves us with 15-bit
15 * fractional part. Thankfully, we need only unsigned values. */
16 #define FIXP_BITS 15
18 #define FIXP_SCALE (1<<FIXP_BITS)
20 #define double_to_fixp(n) ((fixp_t) ((n) * (FIXP_SCALE)))
21 #define fixp_to_double(n) ((double) (n) / FIXP_SCALE)
23 #endif