blob: 62b6a8ae8d33720076641ce5c392602c80b77f16 [file] [log] [blame]
Etan Cohen7ef855e2014-08-20 10:11:11 -07001/* AVR-GCC does not have real double datatype. Instead its double
2 * is equal to float, i.e. 32 bit value. If you need to communicate
3 * with other systems that use double in their .proto files, you
4 * need to do some conversion.
5 *
6 * These functions use bitwise operations to mangle floats into doubles
7 * and then store them in uint64_t datatype.
8 */
9
10#ifndef DOUBLE_CONVERSION
11#define DOUBLE_CONVERSION
12
13#include <stdint.h>
14
15/* Convert native 4-byte float into a 8-byte double. */
16extern uint64_t float_to_double(float value);
17
18/* Convert 8-byte double into native 4-byte float.
19 * Values are rounded to nearest, 0.5 away from zero.
20 * Overflowing values are converted to Inf or -Inf.
21 */
22extern float double_to_float(uint64_t value);
23
24
25#endif
26