Bugzilla – Attachment 36 Details for
Bug 73
sr_si_string_u64() doesn't handle all cases
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to format decimals correctly in sr_si_string_u64()
0001-Format-decimals-correctly-in-sr_si_string_u64.patch (text/plain), 1.75 KB, created by
Peter Stuge
on 2013-06-01 22:16:25 CEST
(
hide
)
Description:
Patch to format decimals correctly in sr_si_string_u64()
Filename:
MIME Type:
Creator:
Peter Stuge
Created:
2013-06-01 22:16:25 CEST
Size:
1.75 KB
patch
obsolete
>From d910db728499145a1329fcaaa0fdf071aefbae50 Mon Sep 17 00:00:00 2001 >From: Peter Stuge <peter@stuge.se> >Date: Sat, 1 Jun 2013 21:55:25 +0200 >Subject: [PATCH] Format decimals correctly in sr_si_string_u64() > >The function would previously format 1004 as 1.4 k and 1004000 as 1.4 M. >The function now formats 1004 as 1.004 k, 1004000 as 1.004000 M >and 1004000000 as 1.004000000 G. > >Fixes #73. >--- > strutil.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > >diff --git a/strutil.c b/strutil.c >index b7b0af1..46f5641 100644 >--- a/strutil.c >+++ b/strutil.c >@@ -70,19 +70,19 @@ SR_API char *sr_si_string_u64(uint64_t x, const char *unit) > if ((x >= SR_GHZ(1)) && (x % SR_GHZ(1) == 0)) { > return g_strdup_printf("%" PRIu64 " G%s", x / SR_GHZ(1), unit); > } else if ((x >= SR_GHZ(1)) && (x % SR_GHZ(1) != 0)) { >- return g_strdup_printf("%" PRIu64 ".%" PRIu64 " G%s", >+ return g_strdup_printf("%" PRIu64 ".%09" PRIu64 " G%s", > x / SR_GHZ(1), x % SR_GHZ(1), unit); > } else if ((x >= SR_MHZ(1)) && (x % SR_MHZ(1) == 0)) { > return g_strdup_printf("%" PRIu64 " M%s", > x / SR_MHZ(1), unit); > } else if ((x >= SR_MHZ(1)) && (x % SR_MHZ(1) != 0)) { >- return g_strdup_printf("%" PRIu64 ".%" PRIu64 " M%s", >+ return g_strdup_printf("%" PRIu64 ".%06" PRIu64 " M%s", > x / SR_MHZ(1), x % SR_MHZ(1), unit); > } else if ((x >= SR_KHZ(1)) && (x % SR_KHZ(1) == 0)) { > return g_strdup_printf("%" PRIu64 " k%s", > x / SR_KHZ(1), unit); > } else if ((x >= SR_KHZ(1)) && (x % SR_KHZ(1) != 0)) { >- return g_strdup_printf("%" PRIu64 ".%" PRIu64 " k%s", >+ return g_strdup_printf("%" PRIu64 ".%03" PRIu64 " k%s", > x / SR_KHZ(1), x % SR_KHZ(1), unit); > } else { > return g_strdup_printf("%" PRIu64 " %s", x, unit); >-- >1.8.1.rc0.2.gfb4c622.dirty >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 73
:
36
|
37
|
38
|
39
|
40
|
41