Arithmetic/Rational: Difference between revisions
Content added Content deleted
(Fixed typo in D entry) |
(Updated D entry) |
||
Line 443: | Line 443: | ||
real toReal() pure const /*nothrow*/ { |
real toReal() pure const /*nothrow*/ { |
||
static if (is(T == BigInt)) |
static if (is(T == BigInt)) |
||
return num.toLong / |
return num.toLong / real(den.toLong); |
||
else |
else |
||
return num / |
return num / real(den); |
||
} |
} |
||
Line 533: | Line 533: | ||
foreach (immutable p; 2 .. 2 ^^ 19) { |
foreach (immutable p; 2 .. 2 ^^ 19) { |
||
auto sum = RatL(1, p); |
auto sum = RatL(1, p); |
||
immutable limit = 1 + cast(uint) |
immutable limit = 1 + cast(uint)real(p).sqrt; |
||
foreach (immutable factor; 2 .. limit) |
foreach (immutable factor; 2 .. limit) |
||
if (p % factor == 0) |
if (p % factor == 0) |