Skip to content
This repository was archived by the owner on Jun 20, 2019. It is now read-only.

Commit 21c04a4

Browse files
committed
Add AArch constants for gammafunction.d
1 parent 1b6c689 commit 21c04a4

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

libphobos/src/std/internal/math/gammafunction.d

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ real igammaTemmeLarge(real a, real x)
249249

250250
public:
251251
/// The maximum value of x for which gamma(x) < real.infinity.
252-
static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended)
252+
static if (floatTraits!(real).realFormat == RealFormat.ieeeQuadruple)
253+
enum real MAXGAMMA = 1755.5483429L;
254+
else static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended)
253255
enum real MAXGAMMA = 1755.5483429L;
254256
else static if (floatTraits!(real).realFormat == RealFormat.ieeeDouble)
255257
enum real MAXGAMMA = 171.6243769L;
@@ -575,7 +577,28 @@ real logGamma(real x)
575577

576578

577579
private {
578-
static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended)
580+
/*
581+
* These value can be calculated like this:
582+
* 1) Get exact real.max/min_normal/epsilon from compiler:
583+
* writefln!"%a"(real.max/min_normal_epsilon)
584+
* 2) Convert for Wolfram Alpha
585+
* 0xf.fffffffffffffffp+16380 ==> (f.fffffffffffffff base 16) * 2^16380
586+
* 3) Calculate result on wofram alpha:
587+
* http://www.wolframalpha.com/input/?i=ln((1.ffffffffffffffffffffffffffff+base+16)+*+2%5E16383)+in+base+2
588+
* 4) Convert to proper format:
589+
* string mantissa = "1.011...";
590+
* write(mantissa[0 .. 2]); mantissa = mantissa[2 .. $];
591+
* for (size_t i = 0; i < mantissa.length/4; i++)
592+
* {
593+
* writef!"%x"(to!ubyte(mantissa[0 .. 4], 2)); mantissa = mantissa[4 .. $];
594+
* }
595+
*/
596+
static if (floatTraits!(real).realFormat == RealFormat.ieeeQuadruple)
597+
{
598+
enum real MAXLOG = 0x1.62e42fefa39ef35793c7673007e6p+13; // log(real.max)
599+
enum real MINLOG = -0x1.6546282207802c89d24d65e96274p+13; // log(real.min_normal*real.epsilon) = log(smallest denormal)
600+
}
601+
else static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended)
579602
{
580603
enum real MAXLOG = 0x1.62e42fefa39ef358p+13L; // log(real.max)
581604
enum real MINLOG = -0x1.6436716d5406e6d8p+13L; // log(real.min_normal*real.epsilon) = log(smallest denormal)

0 commit comments

Comments
 (0)