Skip to content

check for very large or infinity float64 in the alpha parameter to prevent an infinite loop#12

Open
Mrucznik wants to merge 1 commit intoleesper:masterfrom
Mrucznik:master
Open

check for very large or infinity float64 in the alpha parameter to prevent an infinite loop#12
Mrucznik wants to merge 1 commit intoleesper:masterfrom
Mrucznik:master

Conversation

@Mrucznik
Copy link
Copy Markdown

@Mrucznik Mrucznik commented Nov 9, 2022

Hello
There is an infinite loop in the gamma function. Reproduction:

func TestInfinityGamma(t *testing.T) {
	g := NewGammaGenerator(0)

	fmt.Println(g.Gamma(math.MaxFloat64/2, 1)) // this will be ok

	fmt.Println(g.Gamma(math.MaxFloat64, 1)) // infinite loop
	fmt.Println(g.Gamma(math.Inf(1), 1))     // infinite loop
}

I added a check for values bigger than math.MaxFloat64/2, to prevent this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant