Skip to contentSkip to conversation

master - cleanup: avoid printing -0.00

PATCH Zdenek Kabelac 1 participant 1 message Sep 3, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0a389691dcf9a31bb0da26089febb0bdd93545d7
Commit:        0a389691dcf9a31bb0da26089febb0bdd93545d7
Parent:        32d6ca9196591d7f4d820e373fd14fd0f2301914
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu Sep 3 22:51:15 2015 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Thu Sep 3 23:34:37 2015 +0200

cleanup: avoid printing -0.00

Nice trick to not print -0.00 for some percent values.

---
 libdm/libdm-report.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
libdm/libdm-report.c +2 -1
index 2ebb69e..6416f18 100644
@@ -2309,7 +2309,8 @@ static const char *_get_reserved(struct dm_report *rh, unsigned type,
 
 float dm_percent_to_float(dm_percent_t percent)
 {
-	return (float) percent / DM_PERCENT_1;
+	/* Add 0.f to prevent returning -0.00 */
+	return (float) percent / DM_PERCENT_1 + 0.f;
 }
 
 dm_percent_t dm_make_percent(uint64_t numerator, uint64_t denominator)