• Welcome to Valhalla Legends Archive.
 

c++ big integer class

Started by K, October 19, 2004, 11:32 PM

Previous topic - Next topic

K

I've lately revived some interest in my C++ big integer class, and iago was nice enough to lend me some space on his cvs.  If anyone else is interested in contributing, you can send me a forum message / AIM message.
The current interface looks like this:


class vlint
{

public:
vlint();
vlint(operations_t value);
vlint(signed int value);
vlint(const vlint& v);

// not yet implemented
//vlint(const char* value_str_rep);
//vlint(const unsigned char* byte_arr, std::size_t length)

vlint& operator=(const vlint& v);

vlint& operator++();
vlint& operator--();
vlint  operator++(int);
vlint  operator--(int);

bool operator==(const vlint& v) const;
bool operator!=(const vlint& v) const;
bool operator<(const vlint& v) const;
bool operator>(const vlint& v) const;

vlint operator+(const vlint& v) const;
vlint operator-(const vlint& v) const;
vlint operator*(const vlint& v) const;
vlint operator/(const vlint& v) const;
vlint divide(const vlint& right, vlint &remainder) const;

vlint operator%(const vlint& v) const;

vlint& operator+=(const vlint& v);
vlint& operator-=(const vlint& v);
vlint& operator*=(const vlint& v);
vlint& operator/=(const vlint& v);
vlint& operator%=(const vlint& v);

vlint operator-() const;

vlint operator|(const vlint& v) const;
vlint operator&(vlint v) const;
vlint operator^(const vlint& v) const;
vlint operator<<(int bits) const;
vlint operator>>(int bits) const;

vlint& operator|=(const vlint& v);
vlint& operator&=(const vlint& v);
vlint& operator^=(const vlint& v);
vlint& operator<<=(int bits);  
vlint& operator>>=(int bits);

vlint operator~() const;


friend std::ostream& operator<<(std::ostream& o, const vlint& v); // hack: outputs in hex
// not yet implemented
//friend std::istream& operator>>(std::istream& i, vlint& v);

};


Everything that is not commented out is currently implemented and appears to work (I've done some testing, but not extensively).  Some of the code is very old and pretty shoddy and needs a complete re-write.  I'm looking for other people to help out, to get a new perspective.

/K

Edit: before you ask, the "vl" stands for variable length, not valhalla legends   ;)

Kp

Quote from: K on October 19, 2004, 11:32 PMEdit: before you ask, the "vl" stands for variable length, not valhalla legends   ;)

Ah.  I thought it was supposed to be v-lint, a clothing fuzz reference. :)
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Zakath

Heh...that's also how I read it at first.
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.