Skip to content
Snippets Groups Projects
Commit cf82d605 authored by Danny Auble's avatar Danny Auble
Browse files

better documentation on what is going on with convert_num_unit

parent b7347dbd
No related branches found
No related tags found
No related merge requests found
...@@ -3519,7 +3519,11 @@ extern void convert_num_unit(float num, char *buf, int buf_size, int orig_type) ...@@ -3519,7 +3519,11 @@ extern void convert_num_unit(float num, char *buf, int buf_size, int orig_type)
if(orig_type < UNIT_NONE || orig_type > UNIT_PETA) if(orig_type < UNIT_NONE || orig_type > UNIT_PETA)
orig_type = UNIT_UNKNOWN; orig_type = UNIT_UNKNOWN;
i = (int)num; i = (int)num;
if(i == num) /* Here we are checking to see if these numbers are the same,
meaning the float has not floating point. If we do have
floating point print as a float.
*/
if((float)i == num)
snprintf(buf, buf_size, "%d%c", i, unit[orig_type]); snprintf(buf, buf_size, "%d%c", i, unit[orig_type]);
else else
snprintf(buf, buf_size, "%.2f%c", num, unit[orig_type]); snprintf(buf, buf_size, "%.2f%c", num, unit[orig_type]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment