huaiyu wei / ennoTest2
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers double_conversion.h Source File

double_conversion.h

00001 /* AVR-GCC does not have real double datatype. Instead its double
00002  * is equal to float, i.e. 32 bit value. If you need to communicate
00003  * with other systems that use double in their .proto files, you
00004  * need to do some conversion.
00005  *
00006  * These functions use bitwise operations to mangle floats into doubles
00007  * and then store them in uint64_t datatype.
00008  */
00009 
00010 #ifndef DOUBLE_CONVERSION
00011 #define DOUBLE_CONVERSION
00012 
00013 #include <stdint.h>
00014 
00015 /* Convert native 4-byte float into a 8-byte double. */
00016 extern uint64_t float_to_double(float value);
00017 
00018 /* Convert 8-byte double into native 4-byte float.
00019  * Values are rounded to nearest, 0.5 away from zero.
00020  * Overflowing values are converted to Inf or -Inf.
00021  */
00022 extern float double_to_float(uint64_t value);
00023 
00024 
00025 #endif
00026