Skip to content

Commit

Permalink
Add flexibility when using or not legacy units (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Cornu authored Mar 25, 2021
1 parent 03408ac commit bde46c4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/codegen/codegen_c_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2011,8 +2011,14 @@ void CodegenCVisitor::print_nmodl_constants() {
printer->add_newline(2);
printer->add_line("/** constants used in nmodl */");
for (const auto& it: info.factor_definitions) {
printer->add_line("static const double {} = {};"_format(it->get_node_name(),
it->get_value()->get_value()));
#ifdef USE_LEGACY_UNITS
const std::string format_string = "static const double {} = {:g};";
#else
const std::string format_string = "static const double {} = {:.18g};";
#endif
printer->add_line(fmt::format(format_string,
it->get_node_name(),
stod(it->get_value()->get_value())));
}
}
}
Expand Down

0 comments on commit bde46c4

Please sign in to comment.