addaptic

Reference Gamma

lz_gamma

The gamma function, Γ(x).

long lz_gamma( CLZNumber* leftOperand, CLZNumber* targetNumber = nullptr );

Correctly rounded. A whole number is answered exactly, as a factorial: Γ(5) is 4!, which is 24. Anything else above nought comes from Stirling's series after a shift, and anything below nought by the reflection formula.

At nought and the negative whole numbers Γ has poles: kUndefinedResult, flagged not-a-number.

Examples

CallAnswerReturns
lz_gamma( 5 )24kNoError
lz_gamma( 0.5 )1.772453850905516027298167483341145183kNoError
lz_gamma( −0.5 )−3.544907701811032054596334966682290366kNoError
lz_gamma( 0 )not a numberkUndefinedResult
lz_gamma( −2 )not a numberkUndefinedResult

Each answer is what Addaptic printed for the call, at 36 places unless a setting is shown.

Returns

kNoError (0) when the answer is written. Otherwise an error code, with the answer flagged infinite or not-a-number; see Errors and flags.

See also

  • lz_log_gamma The natural logarithm of the gamma function, ln Γ(x), for x above nought.
  • lz_factorial The product of the whole numbers from one to the operand, n!.