UKHAS Wiki

UK High Altitude Society

User Tools

Site Tools


guides:common_coding_errors_payload_testing

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
guides:common_coding_errors_payload_testing [2012/10/09 18:52] danielrichmanguides:common_coding_errors_payload_testing [2012/10/09 18:54] (current) – [Prime Meridian] danielrichman
Line 94: Line 94:
 There's another case to consider. Clearly the idea is to split the float into the an integer and a fraction of an integer (i1 and i2 respectively). There's another case to consider. Clearly the idea is to split the float into the an integer and a fraction of an integer (i1 and i2 respectively).
  
-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, because -0 is the same as zero, and the result would be "0.7". We'll have to handle negative numbers explicitly.+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 "0.7". We'll have to handle negative numbers explicitly
 + 
 +<code c>snprintf(where, buf_size, "%s%i.%06li", (what < 0 ? "-" : ""), labs(i1), i2);</code> 
  
 ==== Equatorial ==== ==== Equatorial ====
guides/common_coding_errors_payload_testing.1349808759.txt.gz · Last modified: 2012/10/09 18:52 by danielrichman

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki