guides:common_coding_errors_payload_testing
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
guides:common_coding_errors_payload_testing [2012/08/28 11:57] – danielrichman | guides:common_coding_errors_payload_testing [2012/10/09 18:54] (current) – [Prime Meridian] danielrichman | ||
---|---|---|---|
Line 18: | Line 18: | ||
char s[30]; | char s[30]; | ||
double lat = 54.086611; | double lat = 54.086611; | ||
- | dstrtof(lat, 8, 6, s); // == " | + | dtostrf(lat, 8, 6, s); // == " |
</ | </ | ||
Line 27: | Line 27: | ||
</ | </ | ||
- | Unfortunately the second one might not always compile. With limited memory on a typical microcontroller, | + | Unfortunately the second one might not always compile. With limited memory on a typical microcontroller, |
==== The hard way ==== | ==== The hard way ==== | ||
Line 91: | Line 91: | ||
<code c>long i2 = labs(lround((lon - i1) * 1000000)); // == 1234</ | <code c>long i2 = labs(lround((lon - i1) * 1000000)); // == 1234</ | ||
+ | |||
+ | There' | ||
+ | |||
+ | The intention is the above code is that the integer part will supply the negative sign if required. However, consider -0.7. i1 would be -0, but -0 == 0, and the result would be " | ||
+ | |||
+ | <code c> | ||
+ | |||
==== Equatorial ==== | ==== Equatorial ==== | ||
- | Theoretically | + | Practically |
==== Fixed version ==== | ==== Fixed version ==== | ||
Line 107: | Line 114: | ||
int i1 = what; | int i1 = what; | ||
long i2 = labs(lround((what - i1) * 1000000)); | long i2 = labs(lround((what - i1) * 1000000)); | ||
- | + | ||
- | snprintf(where, | + | snprintf(where, |
} | } | ||
guides/common_coding_errors_payload_testing.1346155053.txt.gz · Last modified: 2012/08/28 11:57 by danielrichman