diff --git a/ttmath/ttmathbig.h b/ttmath/ttmathbig.h index 68e1037..a850786 100644 --- a/ttmath/ttmathbig.h +++ b/ttmath/ttmathbig.h @@ -985,7 +985,7 @@ public: // man_result = mantissa * ss2.mantissa mantissa.MulInt(ss2, man_result); - int bit = UInt::FindLeadingBitInWord(man_result.table[man]); // man - last word + sint bit = UInt::FindLeadingBitInWord(man_result.table[man]); // man - last word if( bit!=-1 && uint(bit) > (TTMATH_BITS_PER_UINT/2) ) { @@ -4039,11 +4039,11 @@ public: (signs are not checked, we don't check the NaN flag too) sample: - Big<1,1> a, b; - a = " 1234.5678"; - b = "-1234.5677999"; - // binary a: 10011010010.100100010101101101010 - // binary b: -10011010010.100100010101101101000 + Big<1,1> a, b; + a = " 1234.5678"; + b = "-1234.5677999"; + // binary a: 10011010010.100100010101101101010 + // binary b: -10011010010.100100010101101101000 // two last bits are different if( a.AboutEqualWithoutSign(b, 2) ) // the result is true std::cout << "true" << std::endl; @@ -4093,11 +4093,11 @@ public: this method is similar to AboutEqualWithoutSign but the signs are checked now sample: - Big<1,1> a, b; - a = "456.6789"; - b = "456.678901"; - // binary a: 111001000.10101101110011000101111 - // binary b: 111001000.10101101110011000110111 + Big<1,1> a, b; + a = "456.6789"; + b = "456.678901"; + // binary a: 111001000.10101101110011000101111 + // binary b: 111001000.10101101110011000110111 // five last bits are different if( a.AboutEqual(b, 5) ) // the result is true std::cout << "true" << std::endl; diff --git a/ttmath/ttmathparser.h b/ttmath/ttmathparser.h index e145b3d..af5ac5f 100644 --- a/ttmath/ttmathparser.h +++ b/ttmath/ttmathparser.h @@ -1356,6 +1356,8 @@ void Avg(int sindex, int amount_of_args, ValueType & result) + + /*! we use such a method because 'wvsprintf' is not everywhere defined */ @@ -1364,14 +1366,25 @@ void Sprintf(tt_char * buffer, int par) char buf[30]; // char, not tt_char int i; + #ifdef _MSC_VER + #pragma warning( disable: 4996 ) + //warning C4996: 'sprintf': This function or variable may be unsafe. + #endif + sprintf(buf, "%d", par); for(i=0 ; buf[i] != 0 ; ++i) buffer[i] = buf[i]; buffer[i] = 0; + + #ifdef _MSC_VER + #pragma warning( default: 4996 ) + #endif } + + /*! this method returns the value from a user-defined function @@ -1678,7 +1691,7 @@ void ReadValue(Item & result, int reading_base) const tt_char * new_stack_pointer; bool value_read; - int carry = result.value.FromString(pstring, reading_base, &new_stack_pointer, &value_read); + uint carry = result.value.FromString(pstring, reading_base, &new_stack_pointer, &value_read); pstring = new_stack_pointer; if( carry ) @@ -1979,7 +1992,7 @@ return 0; void MakeStandardMathematicOperation(ValueType & value1, typename MatOperator::Type mat_operator, const ValueType & value2) { -int res; +uint res; switch( mat_operator ) { diff --git a/ttmath/ttmathuint_noasm.h b/ttmath/ttmathuint_noasm.h index d0e46a4..b315328 100644 --- a/ttmath/ttmathuint_noasm.h +++ b/ttmath/ttmathuint_noasm.h @@ -741,11 +741,11 @@ namespace ttmath temp1.u_.high = a_.u_.low; temp1.u_.low = b_.u_.high; - res_.u_.high = temp1.u / c; - temp2.u_.high = temp1.u % c; + res_.u_.high = (unsigned int)(temp1.u / c); + temp2.u_.high = (unsigned int)(temp1.u % c); temp2.u_.low = b_.u_.low; - res_.u_.low = temp2.u / c; + res_.u_.low = (unsigned int)(temp2.u / c); *rest = temp2.u % c; *r = res_.u;