123456789101112131415161718192021222324252627282930313233343536 |
- #ifndef BIG_INT_HPP
- #define BIG_INT_HPP
- #include "semi_bitset.hpp"
- template<std::size_t size>
- class BigInt{
- private:
- int signum = 1;
- semi_bitset<size, size >= 1000> bits;
- public:
- inline BigInt(){
-
- }
- inline BigInt(int o){
- if(o < 0){signum = -1;o *= -1;}
- bits.data[bits.length() - 1] = (unsigned int)o;
- }
- inline BigInt(unsigned int o){
- bits.data[bits.length() - 1] = o;
- }
- inline BigInt(long long o){
- if(o < 0){signum = -1;o *= -1;}
- bits.data[bits.length() - 1] = (lower_half);
- bits.data[bits.length() - 2] = (o >> 32);
- }
- inline BigInt(unsigned long long o){
- bits.data[bits.length() - 1] = (o & lower_half);
- bits.data[bits.length() - 2] = (o >> 32);
- }
- template<typename stream, size_t osize>
- inline friend stream& operator<<(stream& s, const BigInt<osize>& o){
- for(size_t i = 0;i < o.bits.length();i++)
- s << std::bitset<32>((uint32_t)(o.bits.data[i] & lower_half));
- return s;
- }
- };
- #endif
|