#include "rar.hpp" #ifndef NATIVE_INT64 Int64::Int64() { } Int64::Int64(uint n) { HighPart=0; LowPart=n; } Int64::Int64(uint HighPart,uint LowPart) { Int64::HighPart=HighPart; Int64::LowPart=LowPart; } /* Int64 Int64::operator = (Int64 n) { HighPart=n.HighPart; LowPart=n.LowPart; return(*this); } */ Int64 Int64::operator << (int n) { Int64 res=*this; while (n--) { res.HighPart<<=1; if (res.LowPart & 0x80000000) res.HighPart|=1; res.LowPart<<=1; } return(res); } Int64 Int64::operator >> (int n) { Int64 res=*this; while (n--) { res.LowPart>>=1; if (res.HighPart & 1) res.LowPart|=0x80000000; res.HighPart>>=1; } return(res); } Int64 operator / (Int64 n1,Int64 n2) { if (n1.HighPart==0 && n2.HighPart==0) return(Int64(0,n1.LowPart/n2.LowPart)); int ShiftCount=0; while (n1>n2) { n2=n2<<1; if (++ShiftCount>64) return(0); } Int64 res=0; while (ShiftCount-- >= 0) { res=res<<1; if (n1>=n2) { n1-=n2; ++res; } n2=n2>>1; } return(res); } Int64 operator * (Int64 n1,Int64 n2) { if (n1<0x10000 && n2<0x10000) return(Int64(0,n1.LowPart*n2.LowPart)); Int64 res=0; for (int I=0;I<64;I++) { if (n2.LowPart & 1) res+=n1; n1=n1<<1; n2=n2>>1; } return(res); } Int64 operator % (Int64 n1,Int64 n2) { if (n1.HighPart==0 && n2.HighPart==0) return(Int64(0,n1.LowPart%n2.LowPart)); return(n1-n1/n2*n2); } Int64 operator + (Int64 n1,Int64 n2) { n1.LowPart+=n2.LowPart; if (n1.LowPart (Int64 n1,Int64 n2) { return((int)n1.HighPart>(int)n2.HighPart || n1.HighPart==n2.HighPart && n1.LowPart>n2.LowPart); } bool operator < (Int64 n1,Int64 n2) { return((int)n1.HighPart<(int)n2.HighPart || n1.HighPart==n2.HighPart && n1.LowPart= (Int64 n1,Int64 n2) { return(n1>n2 || n1==n2); } bool operator <= (Int64 n1,Int64 n2) { return(n1='0' && *Str<='9') { n=n*10+*Str-'0'; Str++; } return(n); }