Home | History | Annotate | only in /external/nanopb-c/examples/using_double_on_avr
Up to higher level directory
NameDateSize
decode_double.c24-Aug-2016765
double_conversion.c24-Aug-20162.6K
double_conversion.h24-Aug-2016749
doubleproto.proto24-Aug-2016338
encode_double.c24-Aug-2016599
Makefile24-Aug-2016594
README.txt24-Aug-20161K
test_conversions.c24-Aug-20161.6K

README.txt

      1 Nanopb example "using_double_on_avr"
      2 ====================================
      3 
      4 Some processors/compilers, such as AVR-GCC, do not support the double
      5 datatype. Instead, they have sizeof(double) == 4. Because protocol
      6 binary format uses the double encoding directly, this causes trouble
      7 if the protocol in .proto requires double fields.
      8 
      9 This directory contains a solution to this problem. It uses uint64_t
     10 to store the raw wire values, because its size is correct on all
     11 platforms. The file double_conversion.c provides functions that
     12 convert these values to/from floats, without relying on compiler
     13 support.
     14 
     15 To use this method, you need to make some modifications to your code:
     16 
     17 1) Change all 'double' fields into 'fixed64' in the .proto.
     18 
     19 2) Whenever writing to a 'double' field, use float_to_double().
     20 
     21 3) Whenever reading a 'double' field, use double_to_float().
     22 
     23 The conversion routines are as accurate as the float datatype can
     24 be. Furthermore, they should handle all special values (NaN, inf, denormalized
     25 numbers) correctly. There are testcases in test_conversions.c.
     26