Accueil > > > BIG SIGNED INTEGER
BIG SIGNED INTEGER
Information sur la source
Description
Un entier de taille non definie. Je poste le code du header, histoire de vous donner une idée.
Source
- #ifndef BIGINT_INC
- #define BIGINT_INC
-
-
- #include <assert.h>
- #include <iostream>
- #include <list>
-
- #ifndef MAX
- #define MAX(a,b) ((a>b)?a:b)
- #endif
-
- #ifndef MIN
- #define MIN(a,b) ((a<b)?a:b)
- #endif
-
-
- class BigInt
- {
- public:
- typedef unsigned char Byte;
-
- BigInt();
- ~BigInt();
- BigInt(const BigInt & br);
- BigInt(unsigned int i);
-
- void operator = (const BigInt & br);
- void operator = (unsigned int i);
- void operator = (int i);
-
- BigInt operator * (const BigInt & br)const;
- BigInt operator * (unsigned int i)const;
- BigInt operator * (Byte b)const;
- BigInt operator + (unsigned int i)const;
- BigInt operator + (const BigInt & br)const;
- BigInt operator - (const BigInt & br)const;
- BigInt operator - ()const;
-
- BigInt operator << (unsigned int i) const;
-
- void operator *= (const BigInt & br);
- void operator *= (unsigned int i);
- void operator += (const BigInt & br);
- void operator += (unsigned int i);
- void operator -= (const BigInt & br);
- void operator -= (unsigned int i);
-
- void operator /= (const BigInt & br);
- void operator ++ ();
- void operator -- ();
-
- bool operator ==(const BigInt & br)const;
- bool operator !=(const BigInt & br)const;
- bool operator <(const BigInt & br)const;
- bool operator >(const BigInt & br)const;
- bool operator <=(const BigInt & br)const;
- bool operator >=(const BigInt & br)const;
-
- static void div(BigInt & q, BigInt & r, const BigInt & f, const BigInt & d);
- static BigInt gcd(BigInt & a, BigInt & b);
-
- void print(std::ostream & out)const;
-
- double to_double() const;
-
- static void test();
- private:
-
- std::list<Byte> data_;
- bool positiv_;
- };
- inline std::ostream & operator << (std::ostream & out, const BigInt & bi){
- bi.print(out);
- return out;
- }
- #endif
#ifndef BIGINT_INC
#define BIGINT_INC
#include <assert.h>
#include <iostream>
#include <list>
#ifndef MAX
#define MAX(a,b) ((a>b)?a:b)
#endif
#ifndef MIN
#define MIN(a,b) ((a<b)?a:b)
#endif
class BigInt
{
public:
typedef unsigned char Byte;
BigInt();
~BigInt();
BigInt(const BigInt & br);
BigInt(unsigned int i);
void operator = (const BigInt & br);
void operator = (unsigned int i);
void operator = (int i);
BigInt operator * (const BigInt & br)const;
BigInt operator * (unsigned int i)const;
BigInt operator * (Byte b)const;
BigInt operator + (unsigned int i)const;
BigInt operator + (const BigInt & br)const;
BigInt operator - (const BigInt & br)const;
BigInt operator - ()const;
BigInt operator << (unsigned int i) const;
void operator *= (const BigInt & br);
void operator *= (unsigned int i);
void operator += (const BigInt & br);
void operator += (unsigned int i);
void operator -= (const BigInt & br);
void operator -= (unsigned int i);
void operator /= (const BigInt & br);
void operator ++ ();
void operator -- ();
bool operator ==(const BigInt & br)const;
bool operator !=(const BigInt & br)const;
bool operator <(const BigInt & br)const;
bool operator >(const BigInt & br)const;
bool operator <=(const BigInt & br)const;
bool operator >=(const BigInt & br)const;
static void div(BigInt & q, BigInt & r, const BigInt & f, const BigInt & d);
static BigInt gcd(BigInt & a, BigInt & b);
void print(std::ostream & out)const;
double to_double() const;
static void test();
private:
std::list<Byte> data_;
bool positiv_;
};
inline std::ostream & operator << (std::ostream & out, const BigInt & bi){
bi.print(out);
return out;
}
#endif
Conclusion
Bug connu (!) : l'affichage par la fonction print est en hexa ... Y en a que ca derrange ? :)
Bug inconnus : yup, pleins ! enfin, j'espere que non ...
J'ai aussi une classe Fraction qui est le rapport de 2 de ces BigInt. Mais le code est encore buggy...
Sinon, l'algo de la division est vraiment TRES POURRIS ! (comprendre PAS RAPIDE)
tib
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
[TECHDAYS2012] OUI J'Y SERAI![TECHDAYS2012] OUI J'Y SERAI! par JeremyJeanson
Bonsoir, Certes, je l'annonce avec un peu de retard, mais je serai effectivement au Techdays demain. Comme l'an dernier, je participerai au programme ATE (Ask The Expert). Si vous avez des questions Workflow, WCF, AppFabric ou plus généralement .net, n'hé...
Cliquez pour lire la suite de l'article par JeremyJeanson TFS INTEGRATION TOOLS - SUIVI DES SYNCHRONISATIONS AVEC REPORTING SERVICESTFS INTEGRATION TOOLS - SUIVI DES SYNCHRONISATIONS AVEC REPORTING SERVICES par vfabing
Afin de s'assurer du bon fonctionnement des différentes synchronisations effectuées par les TFS Integration Tools, 2 rapports sont présents dès l'installation. Il suffit alors d'effectuer les manipulations suivantes pour pouvoir les visualiser : Loca...
Cliquez pour lire la suite de l'article par vfabing CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT)CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT) par FREMYCOMPANY
Bonjour à tous, Je viens de publier une proposition comprenant 5 pseudo-classes pour le CSS Working Group ayant trait à l'état de chargement d'un élément (ex: IMG,VIDEO,AUDIO,OBJECT pour l'HTML.). Si le c½ur vous en dit, vous pouvez retrouver cette p...
Cliquez pour lire la suite de l'article par FREMYCOMPANY MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ?MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ? par ROMELARD Fabrice
Formation initiale Durant la formation, le découpage classique est le suivant (je donnerai les équivalences Suisse lorsque je les connaîtrais) : Ecole primaire jusqu'au Collège : Formation générale permettant d'obtenir les méthodes...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice Y'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENTY'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENT par Aleks
Quand on a ce genre d'erreur sans log :
Et bas on a juste envie de choper le gas de Microsoft qu'a développé ça et lui foutre des baffes de Coboye ! ...
Cliquez pour lire la suite de l'article par Aleks
Forum
RE : ARBRE BINAIRERE : ARBRE BINAIRE par pacotheking
Cliquez pour lire la suite par pacotheking
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|