Issue #21666 has been updated by mtasaka (Mamoru TASAKA).
https://github.com/ruby/ruby/compare/master...nobu:ruby:lgamma-unspecified-v...
Thank you. I've checked the above change and as far as I read the specification (POSIX) this is correct. ---------------------------------------- Bug #21666: Math.lgamma(-1).should == [infinity_value, 1] fails with Fedora glibc-2.42.9000-8.fc44 https://bugs.ruby-lang.org/issues/21666#change-115089 * Author: mtasaka (Mamoru TASAKA) * Status: Open * ruby -v: ruby 3.5.0dev (2025-11-04 master 55257b5038) +PRISM [x86_64-linux] * Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED ---------------------------------------- With Fedora glibc-2.42.9000-8.fc44 the following test: https://github.com/ruby/ruby/blob/cdcb490d2bceb4ff8d6fce349047a2b722e6ae87/s... fails like ``` 1) Math.lgamma returns [Infinity, 1] when passed -1 FAILED Expected [Infinity, -1] == [Infinity, 1] to be truthy but was false /builddir/build/BUILD/ruby-3.5.0_20251103.2332git4001e81a8e-build/ruby-3.5.0-4001e81a8e/spec/ruby/core/math/lgamma_spec.rb:10:in 'block (3 levels) in <top (required)>' /builddir/build/BUILD/ruby-3.5.0_20251103.2332git4001e81a8e-build/ruby-3.5.0-4001e81a8e/spec/ruby/core/math/lgamma_spec.rb:3:in '<top (required)>' ``` (With the help from glibc developer: https://bugzilla.redhat.com/show_bug.cgi?id=2412227 ) POSIX.1-2024 says (ref: https://pubs.opengroup.org/onlinepubs/9799919799/functions/lgamma.html )
If \(x\) is a non-positive integer, a pole error shall occur and lgamma(), lgammaf(), and lgammal() shall return +HUGE_VAL, +HUGE_VALF, and +HUGE_VALL, respectively.
but also says:
The sign of \( \Gamma(x) \) shall be returned in the external integer signgam. If \(x\) is NaN, -Inf, or a negative integer, the value of signgam is **unspecified**.`
So on this line: https://github.com/ruby/ruby/blob/cdcb490d2bceb4ff8d6fce349047a2b722e6ae87/m... when `d` is -1 (or negative integer), the value of `sign` is unspeficied. -- https://bugs.ruby-lang.org/