You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This single-line Haskell code runs in about 0.04 seconds compiled with GHC -O3:
main = print $ (5^4^3^2) `mod` 10
This D2 code runs in about 0.09 seconds (DMD 2.053) showing that this computation is fast enough in D (GHC used GNU multiprecision):
import std.stdio, std.bigint;
void main() {
writeln((BigInt(5) ^^ 4 ^^ 3 ^^ 2) % 10);
}
This Haskell program runs in about 0.24 seconds (GHC -O3), and prints pieces of the number:
y = show ( 5^4^3^2 )
l = length y
main = do
putStrLn ("5**4**3**2 = " ++ take 20 y ++ "..." ++ drop (l-20) y ++ " and has " ++ show l ++ " digits")
A similar D2 program takes about 3.38 seconds, so I think the BigInt->string conversion is significantly slower:
import std.stdio, std.bigint;
void main() {
auto s = toDecimalString(BigInt(5) ^^ 4 ^^ 3 ^^ 2);
writefln("5^4^3^2 = %s..%s (%d digits)", s[0..20], s[$-20..$], s.length);
}
Some info about a proposal to speed up Python division and int->str conversions:
http://fredrik-j.blogspot.com/2008/07/making-division-in-python-faster.htmlhttp://bugs.python.org/issue3451
The text was updated successfully, but these errors were encountered:
bearophile_hugs reported this on 2011-05-15T09:56:05Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=6007
CC List
Description
The text was updated successfully, but these errors were encountered: