Talk:cpp/numeric/valarray/apply
From cppreference.com
< Talk:cpp | numeric/valarray
Any insight into why the code example needs to use std::round()? I do see it get the wrong answer (1 off) without it for the largest couple values. However, int num = std::tgamma(11); gives the correct answer
64.136.209.56 12:54, 1 January 2019 (PST)
- The library
tgamma
likely returns something slightly less than 10!. For your second case, the compiler likely constant folded std::tgamma(11) at compile time to an exact result. T. Canens (talk) 23:08, 1 January 2019 (PST)
Thanks! Constant folding makes sense. I was hoping we'd find some way to add a comment to the example related to this, but I can't think of anything super helpful here. I appreciate the response! 64.136.209.56 17:28, 2 January 2019 (PST)