diff --git a/pp_pack.c b/pp_pack.c index 1d732a8bf7e3..cf1074e23dd4 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -2672,6 +2672,11 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) afloat = -FLT_MAX; else afloat = (float)anv; # else +#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan) + if(Perl_isnan(anv)) + afloat = (float)NV_NAN; + else +#endif /* a simple cast to float is undefined if outside * the range of values that can be represented */ afloat = (float)(anv > FLT_MAX ? NV_INF :