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



  • 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!)



  • x_dawnbeach schrieb:

    1. war das mit main von vc++ vorgegeben

    das ist C++/CLI 😃

    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!)

    Lies doch bitte die Doku, dort steht alles drin.

    MfG

    GPC



  • hab ich ja und trotzdem funktioniert es nicht!!! Ich dachte einer von euch hat das schon mal benutzt oder?



  • CStoll hat doch nen Link gepostet, der alles erläutert:

    #include <iostream>
    #include <cmath>
    #include <gmpxx.h>  //Jetzt passt auch der include
    
    using namespace std;
    
    int main() {
        mpz_class x,y;
        x = 1234;
        y = x+1;
    
        cout<<y<<'\n';
    
        return 0;
    }
    

    MfG

    GPC



  • mpz_class wirdaber nicht erkannt, nur mpz_t! das programm was du über mir genannt hast funzt nicht. 🙂



  • x_dawnbeach schrieb:

    mpz_class wirdaber nicht erkannt, nur mpz_t! das programm was du über mir genannt hast funzt nicht. 🙂

    Was heißt: "wirdaber nicht erkannt"? Gib mal die Meldung des Compilers her, die vollständige.

    Edit: hab die falsche Datei includet und den oberen Post editiert, der passt jetzt. Dann musst du noch folgendes bei den Linkeroptionen eintragen: -lgmpxx -lgmp

    MfG

    GPC


Anmelden zum Antworten