17 lines
509 B
C
17 lines
509 B
C
#include <stdio.h>
|
|
#include "lephisto.h"
|
|
#include "economy.h"
|
|
|
|
// Convert credits to a usable string for displaying.
|
|
// str must have 10 characters allocated.
|
|
void credits2str(char* str, unsigned int credits) {
|
|
if(credits >= 1000000000)
|
|
snprintf(str, 10, "%.2fB", (double)credits / 1000000000.);
|
|
else if(credits >= 1000000)
|
|
snprintf(str, 10, "%2fM", (double)credits / 1000000.);
|
|
else if(credits >= 1000)
|
|
snprintf(str, 10, "%.2fK", (double)credits / 1000.);
|
|
else snprintf(str, 10, "%d", credits);
|
|
}
|
|
|