src/lib/obscure.c 1.53
1.53 2010/01/27 21:04:04 galt
moved new greek byte function to kent/src/lib/obscure.c
Index: src/lib/obscure.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/obscure.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -b -B -U 4 -r1.52 -r1.53
--- src/lib/obscure.c 25 Nov 2009 17:52:55 -0000 1.52
+++ src/lib/obscure.c 27 Jan 2010 21:04:04 -0000 1.53
@@ -569,8 +569,27 @@
sprintLongWithCommas(ascii, l);
fprintf(f, "%s", ascii);
}
+void sprintWithGreekByte(char *s, int slength, long long size)
+/* Numbers formatted with PB, TB, GB, MB, KB, B */
+{
+char *greek[] = {"B", "KB", "MB", "GB", "TB", "PB"};
+int i = 0;
+long long d = 1;
+while ((size/d) >= 1024)
+ {
+ ++i;
+ d *= 1024;
+ }
+double result = ((double)size)/d;
+if (result < 10)
+ safef(s,slength,"%3.1f %s",((double)size)/d, greek[i]);
+else
+ safef(s,slength,"%3.0f %s",((double)size)/d, greek[i]);
+}
+
+
void shuffleArrayOfPointers(void *pointerArray, int arraySize, int shuffleCount)
/* Shuffle array of pointers of given size given number of times. */
{
void **array = pointerArray, *pt;