mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
fixes for -O gen-C++ generation of floating point constants
This commit is contained in:
parent
a93a69ba62
commit
6daf9d5b88
1 changed files with 10 additions and 0 deletions
|
@ -17,6 +17,16 @@ string Fmt(double d) {
|
|||
if ( d == 0.0 && signbit(d) )
|
||||
return "-0.0";
|
||||
|
||||
if ( isinf(d) ) {
|
||||
string infty = "std::numeric_limits<double>::infinity()";
|
||||
if ( d < 0.0 )
|
||||
infty = "-" + infty;
|
||||
return infty;
|
||||
}
|
||||
|
||||
if ( isnan(d) )
|
||||
return "std::numeric_limits<double>::quiet_NaN()";
|
||||
|
||||
// Unfortunately, to_string(double) is hardwired to use %f with
|
||||
// default of 6 digits precision.
|
||||
char buf[8192];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue