2^20991011-1

• To: mathgroup at smc.vnet.net
• Subject: [mg45441] 2^20991011-1
• From: Friedrich Laher <mathefritz at schmieder-laher.de>
• Date: Wed, 7 Jan 2004 17:31:05 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```how can mathematica do that that fast ( 100 seconds on 2.4GHz Athalon )
while the following needs almost 100 minutes
#include<stdio.h>
/*
Zahl = 2^20 996 011 -  1 get decimal representation,
but
base 10^9 Zahl, 9 dec. digits codes binary in 32Bit.

20 996 011*DekadischerLog(2) = 6 320 429, 100 ...
Zahl
has 6 320 431 dec. digits, so needs 702 271 unsigned long's ( of 32 bit ).

20 996 011 bit's are 656 125 *32 + 11, 2^11-1 = 2074
---------------------
1 Stunde 38 Min. 3 Sek
--------------------
*/
unsigned long Zahl[702271], *DezZeiger;
int main()
{
asm("
#			INITIALISIERUNG

PUSHL %ebx
MOVD %esp,%mm3; LEA Zahl+4*702271,%esp

MOVL  \$656125,%ecx
MOVD	%ecx,%mm2; MOVL \$1,%eax; MOVD %eax,%mm1

CLC;CMC;  CLD

LEA Zahl,%edi; MOVD %edi,%mm0

MOV \$2047,%edx; MOVL \$1000000000,%ebx
InitLoop:
SBB %eax,%eax; DIV %ebx; STOSL; LOOP InitLoop; JMP DezStore

#	HAUPTSCHLEIFE
DivLoop:
LODSL; DIVL %ebx
unShortened:
STOSL; LOOP DivLoop
DezStore:
PUSHL %edx
MOVD  %mm2,%ecx; TESTL %ecx,%ecx; JE endCalc

MOVD %mm0,%esi; MOVL %esi,%edi

LODSL; SUBL %edx,%edx; DIVL %ebx

TESTL %eax,%eax
JNE unShortened; PSUBD %mm1,%mm2; LOOP DivLoop; JMP DezStore
endCalc:
MOVL %esp, DezZeiger; MOVD %mm3,%esp
POPL %ebx
");
for(;DezZeiger != Zahl+702271;++DezZeiger)printf("%09u ",*DezZeiger);

printf("\n");
}

```

• Prev by Date: Re: running dos executable from mathematica and reading output
• Next by Date: stupid text formatting question
• Previous by thread: upside-down pdf export
• Next by thread: Re: 2^20991011-1