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

Commit bfe2bbc

Browse files
authored
Merge pull request #584 from jpf91/gammaAArch
AArch64 constants for gammafunction.d
2 parents 1b6c689 + 86ef1b2 commit bfe2bbc

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
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)

libphobos/src/std/math.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -892,11 +892,11 @@ Lret: {}
892892
1.0
893893
];
894894

895-
enum real DP1 =
895+
enum real P1 =
896896
7.853981633974483067550664827649598009884357452392578125E-1L;
897-
enum real DP2 =
897+
enum real P2 =
898898
2.8605943630549158983813312792950660807511260829685741796657E-18L;
899-
enum real DP3 =
899+
enum real P3 =
900900
2.1679525325309452561992610065108379921905808E-35L;
901901
}
902902
else

0 commit comments

Comments
 (0)