Add TNG writing and reading support
[alexxy/gromacs.git] / src / external / tng_io / include / compression / fixpoint.h
1 /* This code is part of the tng compression routines.
2  *
3  * Written by Daniel Spangberg
4  * Copyright (c) 2010, 2013, The GROMACS development team.
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the Revised BSD License.
9  */
10
11 #ifndef FIXPOINT_H
12 #define FIXPOINT_H
13
14 #include "../compression/my64bit.h"
15
16 /* There are at least 32 bits available in a long. */
17 typedef unsigned long fix_t;
18
19 /* Positive double to 32 bit fixed point value */
20 fix_t Ptngc_ud_to_fix_t(double d,double max);
21
22 /* double to signed 32 bit fixed point value */
23 fix_t Ptngc_d_to_fix_t(double d,double max);
24
25 /* 32 bit fixed point value to positive double */
26 double Ptngc_fix_t_to_ud(fix_t f, double max);
27
28 /* signed 32 bit fixed point value to double */
29 double Ptngc_fix_t_to_d(fix_t f, double max);
30
31 /* Convert a floating point variable to two 32 bit integers with range
32    -2.1e9 to 2.1e9 and precision to somewhere around 1e-9. */
33 void Ptngc_d_to_i32x2(double d, fix_t *hi, fix_t *lo);
34
35 /* Convert two 32 bit integers to a floating point variable
36    -2.1e9 to 2.1e9 and precision to somewhere around 1e-9. */
37 double Ptngc_i32x2_to_d(fix_t hi, fix_t lo);
38
39 #endif