Bug 27617 - tgamma integer wrapping results in inaccurate result.
Summary: tgamma integer wrapping results in inaccurate result.
Status: RESOLVED NOTABUG
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: 2.32
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-21 00:26 UTC by Brian Chrisman
Modified: 2021-03-21 08:39 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fw: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Chrisman 2021-03-21 00:26:02 UTC
For integer parameters greater than 6, tgamma(n+1) != n!
(note: 719 and beyond are off-by-one, while the real parameter at the bottom results in 720)

#include <iostream>
#include <cmath>
using namespace std;
int main(void)
{
	uint64_t foo;
	for(int i=0; i < 10; i++)
	{
		foo = tgamma(i);
		cout << foo << "\n";
	}
	cout << tgamma(7.0) << "\n";
}

0
1
1
2
6
24
120
719
5039
40319
720
Comment 1 Brian Chrisman 2021-03-21 01:50:29 UTC
Apologies, this is not a bug as I misread the return types supported to include integers when they don't.
Comment 2 Brian Chrisman 2021-03-21 01:51:27 UTC
tgamma(7) correctly returns 719.9999...