Autor Beitrag
Flamefire
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Fr 04.12.09 20:06 
Ich versuche mit der Bignum2 unit eine berechnung zu machen.
quelle: www.delphi-forum.de/...mp;highlight=bignum2
code sieht so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
        fakt1:=glsys[j,Nulli];
        fakt2:=glsys[i,Nulli];
        for k := 0 to varCt do begin
          if(not RowToDo[k]) then continue;
          glsys[j,k].Multiply(fakt2);
          tmpbn:=glsys[i,k].Product(fakt1);
          glsys[j,k].Sub(tmpbn);
        end;


wenn ich das ausführe so dass z.b. nach dem ersten schleifendurchlauf(k=Nulli) glsys[j,k]=0 ist dann setzt er mir aus irgendeinem grund auch fakt1 auf 0
funktioniert die zuweisung nicht, sodass er das object nicht kopiert, sondern nur den pointer?
wie kann ich das umgehen?

EDIT: falls jemand das gleich prob hat:
zu lösen mit fakt1.Asign(glsys[j,Nulli].Number); wie erwartet... ;-)


Anderes Problem: BigNum2 unterstützt keine negativen werte :-(

Was nun? brauch große Integer. Aber wirklich integer. also auch negative werte
Flamefire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: So 06.12.09 01:24 
habe die bigint als vergleich mal ausprobiert.
die kann zwar negative werte, ist aber anscheinend nicht korrekt. weiß nicht warum, aber sie gibt mir manchmal falsche werte bei einfach operationen wie den obigen...
setzt den MSB eintrag anscheinend falsch bei einer multiplikation oder subtraktion :-(

,uss vl doch die bignum für negative werte umschreiben, falls keiner ne andre idee hat
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 06.12.09 14:18 
Was dir helfen könnte ist ggf. die Funktion BM_Assign bzw. deren Wrapper. Damit wird explizit eine Kopie angefertigt.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.