diff options
author | Henner Zeller <h.zeller@acm.org> | 2021-02-01 11:23:44 -0800 |
---|---|---|
committer | Henner Zeller <h.zeller@acm.org> | 2021-02-01 11:23:44 -0800 |
commit | 5eff0b73ae82ee490be3e732241eb22cb4bff952 (patch) | |
tree | 3bce75dfd8d64f87dca2018c5fd483960faa0b14 /frontends/aiger | |
parent | 7d014902ec579eccd04446131fea4772dd715daf (diff) | |
download | yosys-5eff0b73ae82ee490be3e732241eb22cb4bff952.tar.gz yosys-5eff0b73ae82ee490be3e732241eb22cb4bff952.tar.bz2 yosys-5eff0b73ae82ee490be3e732241eb22cb4bff952.zip |
Provide an integer implementation of decimal_digits().
Signed-off-by: Henner Zeller <h.zeller@acm.org>
Diffstat (limited to 'frontends/aiger')
-rw-r--r-- | frontends/aiger/aigerparse.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/frontends/aiger/aigerparse.cc b/frontends/aiger/aigerparse.cc index 2d7c2187e..463c5965b 100644 --- a/frontends/aiger/aigerparse.cc +++ b/frontends/aiger/aigerparse.cc @@ -55,8 +55,15 @@ inline int32_t from_big_endian(int32_t i32) { #define log_debug2(...) ; //#define log_debug2(...) log_debug(__VA_ARGS__) -static int decimal_digits(unsigned n) { - return n > 1 ? ceil(log10(n)) : 1; +static int decimal_digits(uint32_t n) { + 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 |