suche Bibliothek für Sehr Große Integer Zahlen (am besten mit anleitung)



  • Du kannst mittels

    lint z = 1234;
    std::cout<<z.value();
    

    ausgeben, hier zur Basis zehn.

    Gibst du value ein Argument (von 2-36) mit, wird nach dieser Basis ausgegeben.

    MfG

    GPC



  • wie kann ich nun noch aus einem lint wert die wurzel ziehen?dann wäre mein problem gelöst.



  • warum kann man denn diesen code nicht compilieren??

    #include <iostream>
    #include <lint.h>
    
    using namespace std;
    
    int main()
    {
    	lint n1=5643;
    	cout<<n1.value();
    
    	return 0;
    }
    

    fehlermeldungen:

    --------------------Konfiguration: lint - Win32 Debug--------------------
    Kompilierung läuft...
    lint.cpp
    Linker-Vorgang läuft...
    lint.obj : error LNK2001: Nichtaufgeloestes externes Symbol "public: __thiscall lint::~lint(void)" (??1lint@@QAE@XZ)
    lint.obj : error LNK2001: Nichtaufgeloestes externes Symbol "public: __thiscall lint::lint(long)" (??0lint@@QAE@J@Z)
    Debug/lint.exe : fatal error LNK1120: 2 unaufgeloeste externe Verweise
    Fehler beim Ausführen von link.exe.
    
    lint.exe - 3 Fehler, 0 Warnung(en)
    

    die meldungen sagen mir ehrlich gesagt garnichts und ich kann beim besten willen keinen fehler im code erkennen, oder muss man lint doch anders benutzen?
    muss man bei cin was beachten oder kann man einfach

    lint n;
    cin>>n;
    

    schreiben?

    thx so far, Mr. Pink



  • nim einfach fprint(lint_zahl) aus der stdio.h bibliothek.
    aber wie zieh ich nun eine wurzel aus einem lint wert?



  • @Mr. Pink
    Du hast scheinbar die lint.o (aus der lint.cpp) nicht mitgelinkt.

    @x_dawnbeach
    Diese Funktion ist da nicht dabei. Du müsstest sie selber implementieren. Dieses Verfahren wäre möglich
    http://de.wikipedia.org/wiki/Babylonisches_Wurzelziehen
    evtl. kann man auch auf die Wurzel verzichten. Wenn das Ergebnis der Wurzel nur verglichen werden soll ist das einfach (Quadrieren).
    Das Ergebnis muss aber in ein double oder so passen.

    [edit]Antwort an x_dawnbeach hinzugefügt.[edit]



  • Du hast scheinbar die lint.o (aus der lint.cpp) nicht mitgelinkt.

    aha, und wie geht das? 🤡
    arbeite erst seit ganz kurzer zeit mit c++ und habe deshalb kaum ahnung, fand das thema aber mal ganz interessant.... 😮
    wie linke ich das denn mit??? habe visual c++ (falls das wichtig ist)
    danke 😕



  • Bei Visual C++ fügst du einfach die lint.cpp zu deinem Projekt hinzu und es müsste gehen.



  • nee, geht nicht, hab die hinzugefügt, aber:

    --------------------Konfiguration: big numbers - Win32 Debug--------------------
    Kompilierung läuft...
    bn.cpp
    lint.cpp
    c:\lint.cpp(449) : error C2361: Initialisierung von 'i' durch 'default'-Marke übersprungen
            c:\lint.cpp(438) : Siehe Deklaration von 'i'
    Fehler beim Ausführen von cl.exe.
    
    big numbers.exe - 1 Fehler, 0 Warnung(en)
    

    ist also nen fehler in der lint.cpp, an der ich aber nix geändert habe.

    so kann nicht mal diese programm kompiliert werden:

    #include <iostream>
    #include <lint.h>
    
    using namespace std;
    
    int main()
    {
    	return 0;
    }
    

    wie haben es denn die gemacht, bei denen es anscheinend problemlos geht???



  • ich habe zum bsp den befehl fprint("dieser text soll ausgegeben werden"); benutzt. du musst oben aber #define "stdio.h" hinzufügen (nach den anderen #define's). dan ging alles bei mir.



  • ich habe nun flgende fehlermelungen im lint.h gefunden:

    f:\prime\prime\lint.cpp(58) : warning C4793: '__asm' : causes native code generation for function 'lint::lint(long *,unsigned int)'
    f:\prime\prime\lint.h(45) : see declaration of 'lint::lint'
    f:\prime\prime\lint.cpp(82) : warning C4793: '__asm' : causes native code generation for function 'void lint::copy_from(lint &)'
    f:\prime\prime\lint.h(35) : see declaration of 'lint::copy_from'
    f:\prime\prime\lint.cpp(134) : warning C4793: '__asm' : causes native code generation for function 'void lint::not(void)'
    f:\prime\prime\lint.h(38) : see declaration of 'lint::not'
    f:\prime\prime\lint.cpp(163) : warning C4793: '__asm' : causes native code generation for function 'lint &lint::operator =(long)'
    f:\prime\prime\lint.h(49) : see declaration of 'lint::operator ='
    f:\prime\prime\lint.cpp(191) : warning C4793: '__asm' : causes native code generation for function 'lint &lint::operator ++(void)'
    f:\prime\prime\lint.h(52) : see declaration of 'lint::operator ++'
    f:\prime\prime\lint.cpp(223) : warning C4793: '__asm' : causes native code generation for function 'lint &lint::operator --(void)'
    f:\prime\prime\lint.h(54) : see declaration of 'lint::operator --'
    f:\prime\prime\lint.cpp(442) : warning C4996: '_itoa' was declared deprecated
    C:\Programme\Microsoft Visual Studio 8\VC\include\stdlib.h(491) : see declaration of '_itoa'
    Message: 'This function or variable may be unsafe. Consider using _itoa_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
    f:\prime\prime\lint.cpp(443) : warning C4996: 'strcat' was declared deprecated
    C:\Programme\Microsoft Visual Studio 8\VC\include\string.h(78) : see declaration of 'strcat'
    Message: 'This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
    f:\prime\prime\lint.cpp(474) : warning C4996: 'strrev' was declared deprecated
    C:\Programme\Microsoft Visual Studio 8\VC\include\string.h(217) : see declaration of 'strrev'
    Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strrev. See online help for details.'
    f:\prime\prime\lint.cpp(477) : warning C4996: 'strncpy' was declared deprecated
    C:\Programme\Microsoft Visual Studio 8\VC\include\string.h(156) : see declaration of 'strncpy'
    Message: 'This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
    f:\prime\prime\lint.cpp(495) : warning C4793: '__asm' : causes native code generation for function 'lint &operator +(lint &,long)'
    f:\prime\prime\lint.h(85) : see declaration of 'operator +'
    f:\prime\prime\lint.cpp(490) : error C2711: 'operator +' : this functon cannot be compiled as managed, consider using #pragma unmanaged
    The function uses inline assembler or an unsupported intrinsic function
    f:\prime\prime\lint.cpp(495) : see source of the previous compiler diagnostic
    f:\prime\prime\lint.cpp(513) : error C3821: 'lint &operator +(lint &,long)': managed type or function cannot be used in an unmanaged function
    presence of '__asm' or '_setjmp' makes a function unmanaged
    f:\prime\prime\lint.cpp(526) : warning C4793: '__asm' : causes native code generation for function 'lint &operator +(lint &,lint &)'
    f:\prime\prime\lint.h(87) : see declaration of 'operator +'
    f:\prime\prime\lint.cpp(521) : error C2711: 'operator +' : this functon cannot be compiled as managed, consider using #pragma unmanaged
    The function uses inline assembler or an unsupported intrinsic function
    f:\prime\prime\lint.cpp(526) : see source of the previous compiler diagnostic
    f:\prime\prime\lint.cpp(542) : error C3821: 'lint &operator +(lint &,lint &)': managed type or function cannot be used in an unmanaged function
    presence of '__asm' or '_setjmp' makes a function unmanaged
    f:\prime\prime\lint.cpp(549) : warning C4793: '__asm' : causes native code generation for function 'lint &operator -(lint &,long)'
    f:\prime\prime\lint.h(89) : see declaration of 'operator -'
    f:\prime\prime\lint.cpp(545) : error C2711: 'operator -' : this functon cannot be compiled as managed, consider using #pragma unmanaged
    The function uses inline assembler or an unsupported intrinsic function
    f:\prime\prime\lint.cpp(549) : see source of the previous compiler diagnostic
    f:\prime\prime\lint.cpp(564) : error C3821: 'lint &operator -(lint &,long)': managed type or function cannot be used in an unmanaged function
    presence of '__asm' or '_setjmp' makes a function unmanaged
    f:\prime\prime\lint.cpp(579) : warning C4793: '__asm' : causes native code generation for function 'lint &operator -(lint &,lint &)'
    f:\prime\prime\lint.h(91) : see declaration of 'operator -'
    f:\prime\prime\lint.cpp(574) : error C2711: 'operator -' : this functon cannot be compiled as managed, consider using #pragma unmanaged
    The function uses inline assembler or an unsupported intrinsic function
    f:\prime\prime\lint.cpp(579) : see source of the previous compiler diagnostic
    f:\prime\prime\lint.cpp(595) : error C3821: 'lint &operator -(lint &,lint &)': managed type or function cannot be used in an unmanaged function
    presence of '__asm' or '_setjmp' makes a function unmanaged
    f:\prime\prime\lint.cpp(610) : warning C4793: '__asm' : causes native code generation for function 'lint &operator <<(lint &,long)'
    f:\prime\prime\lint.h(93) : see declaration of 'operator <<'
    f:\prime\prime\lint.cpp(599) : error C2711: 'operator <<' : this functon cannot be compiled as managed, consider using #pragma unmanaged
    The function uses inline assembler or an unsupported intrinsic function
    f:\prime\prime\lint.cpp(610) : see source of the previous compiler diagnostic
    f:\prime\prime\lint.cpp(649) : error C3821: 'lint &operator <<(lint &,long)': managed type or function cannot be used in an unmanaged function
    presence of '__asm' or '_setjmp' makes a function unmanaged
    f:\prime\prime\lint.cpp(682) : warning C4793: '__asm' : causes native code generation for function 'lint &operator >>(lint &,long)'
    f:\prime\prime\lint.h(96) : see declaration of 'operator >>'
    f:\prime\prime\lint.cpp(671) : error C2711: 'operator >>' : this functon cannot be compiled as managed, consider using #pragma unmanaged
    The function uses inline assembler or an unsupported intrinsic function
    f:\prime\prime\lint.cpp(682) : see source of the previous compiler diagnostic
    f:\prime\prime\lint.cpp(726) : error C3821: 'lint &operator >>(lint &,long)': managed type or function cannot be used in an unmanaged function
    presence of '__asm' or '_setjmp' makes a function unmanaged
    f:\prime\prime\lint.cpp(756) : warning C4793: '__asm' : causes native code generation for function 'lint &operator *(lint &,long)'
    f:\prime\prime\lint.h(99) : see declaration of 'operator *'
    f:\prime\prime\lint.cpp(749) : error C2711: 'operator *' : this functon cannot be compiled as managed, consider using #pragma unmanaged
    The function uses inline assembler or an unsupported intrinsic function
    f:\prime\prime\lint.cpp(756) : see source of the previous compiler diagnostic
    f:\prime\prime\lint.cpp(773) : error C3821: 'lint &operator *(lint &,long)': managed type or function cannot be used in an unmanaged function
    presence of '__asm' or '_setjmp' makes a function unmanaged
    f:\prime\prime\lint.cpp(841) : warning C4793: '__asm' : causes native code generation for function 'void div_mod_calculate(lint &,lint &,lint &,lint &)'
    f:\prime\prime\lint.h(37) : see declaration of 'div_mod_calculate'
    f:\prime\prime\lint.cpp(805) : error C2711: 'div_mod_calculate' : this functon cannot be compiled as managed, consider using #pragma unmanaged
    The function uses inline assembler or an unsupported intrinsic function
    f:\prime\prime\lint.cpp(841) : see source of the previous compiler diagnostic
    f:\prime\prime\lint.cpp(923) : error C3821: 'void div_mod_calculate(lint &,lint &,lint &,lint &)': managed type or function cannot be used in an unmanaged function
    presence of '__asm' or '_setjmp' makes a function unmanaged
    f:\prime\prime\lint.cpp(968) : warning C4793: '__asm' : causes native code generation for function 'bool operator <(lint &,lint &)'
    f:\prime\prime\lint.h(118) : see declaration of 'operator <'
    f:\prime\prime\lint.cpp(1017) : warning C4793: '__asm' : causes native code generation for function 'bool operator <=(lint &,lint &)'
    f:\prime\prime\lint.h(122) : see declaration of 'operator <='
    f:\prime\prime\lint.cpp(1068) : warning C4793: '__asm' : causes native code generation for function 'bool operator >(lint &,lint &)'
    f:\prime\prime\lint.h(126) : see declaration of 'operator >'
    f:\prime\prime\lint.cpp(1114) : warning C4793: '__asm' : causes native code generation for function 'bool operator >=(lint &,lint &)'
    f:\prime\prime\lint.h(130) : see declaration of 'operator >='
    f:\prime\prime\lint.cpp(1164) : warning C4793: '__asm' : causes native code generation for function 'bool operator ==(lint &,lint &)'
    f:\prime\prime\lint.h(112) : see declaration of 'operator =='
    f:\prime\prime\lint.cpp(1230) : warning C4793: '__asm' : causes native code generation for function 'lint &operator &(lint &,lint &)'
    f:\prime\prime\lint.h(136) : see declaration of 'operator &'
    f:\prime\prime\lint.cpp(1223) : error C2711: 'operator &' : this functon cannot be compiled as managed, consider using #pragma unmanaged
    The function uses inline assembler or an unsupported intrinsic function
    f:\prime\prime\lint.cpp(1230) : see source of the previous compiler diagnostic
    f:\prime\prime\lint.cpp(1243) : error C3821: 'lint &operator &(lint &,lint &)': managed type or function cannot be used in an unmanaged function
    presence of '__asm' or '_setjmp' makes a function unmanaged
    f:\prime\prime\lint.cpp(1270) : warning C4793: '__asm' : causes native code generation for function 'lint &operator |(lint &,lint &)'
    f:\prime\prime\lint.h(140) : see declaration of 'operator |'
    f:\prime\prime\lint.cpp(1263) : error C2711: 'operator |' : this functon cannot be compiled as managed, consider using #pragma unmanaged
    The function uses inline assembler or an unsupported intrinsic function
    f:\prime\prime\lint.cpp(1270) : see source of the previous compiler diagnostic
    f:\prime\prime\lint.cpp(1283) : error C3821: 'lint &operator |(lint &,lint &)': managed type or function cannot be used in an unmanaged function
    presence of '__asm' or '_setjmp' makes a function unmanaged
    f:\prime\prime\lint.cpp(1310) : warning C4793: '__asm' : causes native code generation for function 'lint &operator ^(lint &,lint &)'
    f:\prime\prime\lint.h(144) : see declaration of 'operator ^'
    f:\prime\prime\lint.cpp(1303) : error C2711: 'operator ^' : this functon cannot be compiled as managed, consider using #pragma unmanaged
    The function uses inline assembler or an unsupported intrinsic function
    f:\prime\prime\lint.cpp(1310) : see source of the previous compiler diagnostic
    f:\prime\prime\lint.cpp(1323) : error C3821: 'lint &operator ^(lint &,lint &)': managed type or function cannot be used in an unmanaged function
    presence of '__asm' or '_setjmp' makes a function unmanaged

    wie kann ich diese lösen?



  • @Mr. Pink
    Liegt der Header im aktuellen Verzeichnis? Wenn ja, dann nicht #include <lint.h> sondern #include "lint.h"

    x_dawnbeach schrieb:

    nim einfach fprint(lint_zahl) aus der stdio.h bibliothek.

    Nein, denn erstens heißt es printf (bzw. fprintf) und zweitens ist das C, wir programmieren sauberes C++. Und dazu gehören eben die Stream-Klassen, also cout und cin.

    MfG

    GPC



  • zusammenfassend kann ich nun sagen das keine der genannten varianten funktioniert. kennt nun also jemand eine bibliothek oder eine methode einen beliebig großen int typ zu definieren (mit div, mod, pow2, ++, --,...)?und ich möchte die jenigen bitten, die eine löung haben, auch zu zeigen, wie diese angewandt werden soll. Danke für alle bisherigen bemühungen, wäre schön wenn jemand noch eine lösung hat,
    euer
    x_dawnbeach.



  • hmja, bei mir kommt auch der selbe fehler wenn ich die dateien ins projektverzeichnis kopiere, liegt also nicht daran...
    trotzdem danke für die mühen



  • x_dawnbeach schrieb:

    zusammenfassend kann ich nun sagen das keine der genannten varianten funktioniert. kennt nun also jemand eine bibliothek oder eine methode einen beliebig großen int typ zu definieren (mit div, mod, pow2, ++, --,...)?

    doch gmp sollte das alles liefern.. einfach mal googlen..



  • Allerdings ist die GMP unter Windows nicht ganz trivial zu bauen. Brauchst halt erst cygwin oder mingw. Es ist zwar unter swox.com/gmp dokumentiert, aber wenn man UNIX, und speziell GNU nicht kennt, dürfte man damit ein bisschen zu kämpfen haben.



  • kann den hier keiner mal ne kurze und verständliche anleitung geben wie ich gmp in visual c++ studio 2005 express implementiere?



  • Das erste Ergebnis einer Suche nach

    gmp vc++

    hat ergeben, dass es sowohl Kompilier-Anleitungen als auch fertige Kompilate für Visual C++ gibt: http://www.cs.nyu.edu/exact/core/gmp/



  • so ich habe jetzt das ganze in mein projekt implementiert. vc++ erkennt auch alles, bloß ich komm absolut nicht mit mpz_t klar. wie kann man den variablen dieses typs werte zuweisen und mit den dann noch arbeite?
    ich hab hier mal ein bsp Programm:

    #include "stdafx.h"
    #include "math.h"
    #include "stdio.h"
    #include <gmp.h>
    
    int main(array<System::String ^> ^args)
    {
    mpz_t x,y;
    mpz_init (x);
    mpz_init (y);
    x=1234;
    y=x+1;
    Console::WriteLine(y);
    return 0;
    }
    

    hier funktionieren bspweise die Operatoren "=" und "+" nicht. wie kann ich sonst mit mpz_t zahlen arbeiten?oder überhaupt erstmal den etwas zuweisen?
    ich habe zwar schon unter:
    http://www.swox.com/gmp/manual/
    geguckt aber keine richtige antwort gefunden. kann mir jemand weiter helfen bzw. dieses Programm mal korrigieren?



  • 1. Was soll denn das sein?

    int main(array<System::String ^> ^args)
    

    Das erinnert mich entfernt an Pascal.

    2. Wenn du unbedingt die C-Typen verwenden willst, mußt du auch die dazugehörigen Funktionen verwenden - mpz_set, mpz_add,... Alternativ dazu kannst du das C++ Klasseninterface (mpz_class) verwenden, die definiert die gängigen mathematischen Operatoren.



  • 1. war das mit main von vc++ vorgegeben
    und
    2.
    ich war auch schon so schlau das, man das so irgendwie machen muss.
    wie funktioniert das aber nun genau an meinem zuletzt genanntem beispiel?
    (Da hat es nämlich nicht funktioniert!)


Anmelden zum Antworten