#include "format.h"
#include <assert.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
Go to the source code of this file.
◆ kissat_format_bytes()
| const char * kissat_format_bytes |
( |
kormat * | format, |
|
|
uint64_t | bytes ) |
Definition at line 59 of file format.c.
59 {
61 if (bytes < (1u << 10))
62 sprintf (res,
"%" PRIu64
" bytes", bytes);
63 else if (bytes < (1u << 20))
64 sprintf (res,
"%" PRIu64
" bytes (%" PRIu64
" KB)", bytes,
65 (bytes + (1 << 9)) >> 10);
66 else if (bytes < (1u << 30))
67 sprintf (res,
"%" PRIu64
" bytes (%" PRIu64
" MB)", bytes,
68 (bytes + (1u << 19)) >> 20);
69 else
70 sprintf (res,
"%" PRIu64
" bytes (%" PRIu64
" GB)", bytes,
71 (bytes + (1u << 29)) >> 30);
72 return res;
73}
◆ kissat_format_count()
| const char * kissat_format_count |
( |
kormat * | format, |
|
|
uint64_t | w ) |
Definition at line 35 of file format.c.
35 {
37 format_count (res, w);
38 return res;
39}
◆ kissat_format_ordinal()
| const char * kissat_format_ordinal |
( |
kormat * | format, |
|
|
uint64_t | ordinal ) |
Definition at line 123 of file format.c.
123 {
124 char const *suffix;
125 unsigned mod100 = ordinal % 100;
126 if (10 <= mod100 && mod100 <= 19)
127 suffix = "th";
128 else {
129 switch (mod100 % 10) {
130 case 1:
131 suffix = "st";
132 break;
133 case 2:
134 suffix = "nd";
135 break;
136 case 3:
137 suffix = "rd";
138 break;
139 default:
140 suffix = "th";
141 break;
142 }
143 }
145 sprintf (res,
"%" PRIu64
"%s", ordinal, suffix);
146 return res;
147}
◆ kissat_format_signs()
| const char * kissat_format_signs |
( |
kormat * | format, |
|
|
unsigned | size, |
|
|
word | signs ) |
Definition at line 111 of file format.c.
112 {
117 for (
unsigned i = 0; i <
size; i++, bit <<= 1)
118 *
p++ = (bit & signs) ?
'1' :
'0';
120 return res;
121}
#define KISSAT_assert(ignore)
unsigned __int64 word
DECLARATIONS ///.
◆ kissat_format_time()
| const char * kissat_format_time |
( |
kormat * | format, |
|
|
double | seconds ) |
Definition at line 75 of file format.c.
75 {
76 if (!seconds)
77 return "0s";
79 uint64_t rounded = round (seconds);
80 uint64_t minutes = rounded / 60;
81 rounded %= 60;
82 uint64_t hours = minutes / 60;
83 minutes %= 60;
84 uint64_t days = hours / 24;
85 hours %= 24;
86 char *tmp = res;
87 if (days) {
88 sprintf (res,
"%" PRIu64
"d", days);
90 }
91 if (hours) {
92 if (tmp != res)
93 *tmp++ = ' ';
94 sprintf (tmp,
"%" PRIu64
"h", hours);
96 }
97 if (minutes) {
98 if (tmp != res)
99 *tmp++ = ' ';
100 sprintf (tmp,
"%" PRIu64
"m", minutes);
102 }
103 if (rounded) {
104 if (tmp != res)
105 *tmp++ = ' ';
106 sprintf (tmp,
"%" PRIu64
"s", rounded);
107 }
108 return res;
109}
◆ kissat_format_value()
| const char * kissat_format_value |
( |
kormat * | format, |
|
|
bool | boolean, |
|
|
int | value ) |
Definition at line 41 of file format.c.
41 {
43 return "true";
44 if (
boolean && !
value)
45 return "false";
47 return "INT_MAX";
49 return "INT_MIN";
52 *res = '-';
54 } else
55 format_count (res,
value);
56 return res;
57}
ABC_NAMESPACE_IMPL_START typedef signed char value
◆ kissat_next_format_string()
Definition at line 12 of file format.c.
12 {
14 char *res = format->
str[format->
pos++];
17 return res;
18}
char str[NUM_FORMAT_STRINGS][FORMAT_STRING_SIZE]