diff --git a/ttmath/ttmathbig.h b/ttmath/ttmathbig.h index b51d42b..6be5d9b 100644 --- a/ttmath/ttmathbig.h +++ b/ttmath/ttmathbig.h @@ -2459,6 +2459,8 @@ public: if( IsSign() ) return 1; + + return 0; } @@ -2835,18 +2837,18 @@ private: The first bit is the sign bit, S, the next eight bits are the exponent bits, 'E', and the final 23 bits are the fraction 'F': - S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF - 0 1 8 9 31 + S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF + 0 1 8 9 31 - The value V represented by the word may be determined as follows: - - * If E=255 and F is nonzero, then V=NaN ("Not a number") - * If E=255 and F is zero and S is 1, then V=-Infinity - * If E=255 and F is zero and S is 0, then V=Infinity - * If 0 temp; // 64 bits container + + uint c = ToUInt(temp); + temp.ToUInt(result); + + return c; + } + + + /*! + this method converts 'this' into 'result' (64 bit unsigned integer) + if the value is too big this method returns a carry (1) + */ + uint ToInt(ulint & result) const + { + return ToUInt(result); + } + + + /*! + this method converts 'this' into 'result' (64 bit unsigned integer) + if the value is too big this method returns a carry (1) + */ + uint ToInt(slint & result) const + { + Int<2> temp; // 64 bits container + + uint c = ToInt(temp); + temp.ToInt(result); + + return c; + } + /*! a method for converting 'ulint' (64bit unsigned integer) to this class @@ -3293,6 +3335,56 @@ public: #ifdef TTMATH_PLATFORM64 + + /*! + this method converts 'this' into 'result' (32 bit unsigned integer) + ***this method is created only on a 64bit platform*** + if the value is too big this method returns a carry (1) + */ + uint ToUInt(unsigned int & result) const + { + uint result_uint; + + uint c = ToUInt(result_uint); + result = (unsigned int)result_uint; + + if( c || result_uint != uint(result) ) + return 1; + + return 0; + } + + + /*! + this method converts 'this' into 'result' (32 bit unsigned integer) + ***this method is created only on a 64bit platform*** + if the value is too big this method returns a carry (1) + */ + uint ToInt(unsigned int & result) const + { + return ToUInt(result); + } + + + /*! + this method converts 'this' into 'result' (32 bit signed integer) + ***this method is created only on a 64bit platform*** + if the value is too big this method returns a carry (1) + */ + uint ToInt(signed int & result) const + { + sint result_sint; + + uint c = ToInt(result_sint); + result = (signed int)result_sint; + + if( c || result_sint != sint(result) ) + return 1; + + return 0; + } + + /* this method converts 32 bit unsigned int to this class ***this method is created only on a 64bit platform*** diff --git a/ttmath/ttmathuint.h b/ttmath/ttmathuint.h index 4dd7086..812dff5 100644 --- a/ttmath/ttmathuint.h +++ b/ttmath/ttmathuint.h @@ -2850,7 +2850,6 @@ public: */ uint FromUInt(unsigned int i) { - // !! need testing return FromUInt(uint(i)); } @@ -2860,7 +2859,6 @@ public: */ uint FromInt(unsigned int i) { - // !! need testing return FromUInt(uint(i)); } @@ -2871,7 +2869,6 @@ public: */ uint FromInt(signed int i) { - // !! need testing return FromInt(sint(i)); } diff --git a/ttmath/ttmathuint_x86_64_msvc.asm b/ttmath/ttmathuint_x86_64_msvc.asm index d2ea969..b7c85c2 100644 --- a/ttmath/ttmathuint_x86_64_msvc.asm +++ b/ttmath/ttmathuint_x86_64_msvc.asm @@ -36,9 +36,9 @@ ; ; -; compile with debug info: ml64.exe /Zd /Zi ttmathuint_x86_64_msvc.asm -; compile without debug info: ml64.exe ttmathuint_x86_64_msvc.asm -; this create ttmathuint_x86_64_msvc.obj file which can be linked with your program +; compile with debug info: ml64.exe /c /Zd /Zi ttmathuint_x86_64_msvc.asm +; compile without debug info: ml64.exe /c ttmathuint_x86_64_msvc.asm +; this creates ttmathuint_x86_64_msvc.obj file which can be linked with your program ; PUBLIC ttmath_adc_x64