mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-12 20:18:20 +00:00
Provide an integer implementation of decimal_digits().
Signed-off-by: Henner Zeller <h.zeller@acm.org>
This commit is contained in:
parent
7d014902ec
commit
5eff0b73ae
|
@ -55,8 +55,15 @@ inline int32_t from_big_endian(int32_t i32) {
|
||||||
#define log_debug2(...) ;
|
#define log_debug2(...) ;
|
||||||
//#define log_debug2(...) log_debug(__VA_ARGS__)
|
//#define log_debug2(...) log_debug(__VA_ARGS__)
|
||||||
|
|
||||||
static int decimal_digits(unsigned n) {
|
static int decimal_digits(uint32_t n) {
|
||||||
return n > 1 ? ceil(log10(n)) : 1;
|
static uint32_t digit_cutoff[9] = {
|
||||||
|
10, 100, 1000, 10000, 100000,
|
||||||
|
1000000, 10000000, 100000000, 1000000000
|
||||||
|
};
|
||||||
|
for (int i = 0; i < 9; ++i) {
|
||||||
|
if (n < digit_cutoff[i]) return i + 1;
|
||||||
|
}
|
||||||
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ConstEvalAig
|
struct ConstEvalAig
|
||||||
|
|
Loading…
Reference in a new issue