Mercurial > hg > octave-lyh
diff liboctave/oct-inttypes.cc @ 11586:12df7854fa7c
strip trailing whitespace from source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:24:59 -0500 |
parents | fd0a3ac60b0e |
children | 15eefbd9d4e8 |
line wrap: on
line diff
--- a/liboctave/oct-inttypes.cc +++ b/liboctave/oct-inttypes.cc @@ -1,7 +1,7 @@ /* Copyright (C) 2004-2011 John W. Eaton -Copyright (C) 2008-2009 Jaroslav Hajek +Copyright (C) 2008-2009 Jaroslav Hajek This file is part of Octave. @@ -35,7 +35,7 @@ template<class T> const octave_int<T> octave_int<T>::one (static_cast<T> (1)); -// define type names. +// define type names. #define DECLARE_OCTAVE_INT_TYPENAME(TYPE, TYPENAME) \ template <> \ OCTAVE_API const char * \ @@ -54,8 +54,8 @@ // Define comparison operators -template <class xop> -bool +template <class xop> +bool octave_int_cmp_op::emulate_mop (uint64_t x, double y) { static const double xxup = std::numeric_limits<uint64_t>::max (); @@ -74,8 +74,8 @@ } } -template <class xop> -bool +template <class xop> +bool octave_int_cmp_op::emulate_mop (int64_t x, double y) { static const double xxup = std::numeric_limits<int64_t>::max (); @@ -121,16 +121,16 @@ DEFINE_REVERTED_OPERATOR(le,ge); DEFINE_REVERTED_OPERATOR(ge,le); -template <class xop> -bool +template <class xop> +bool octave_int_cmp_op::emulate_mop (double x, uint64_t y) { typedef typename rev_op<xop>::op rop; return mop<rop> (y, x); } -template <class xop> -bool +template <class xop> +bool octave_int_cmp_op::emulate_mop (double x, int64_t y) { typedef typename rev_op<xop>::op rop; @@ -141,20 +141,20 @@ // Define handlers for int64 multiplication template <> -uint64_t +uint64_t octave_int_arith_base<uint64_t, false>::mul (uint64_t x, uint64_t y) -{ +{ // Get upper words uint64_t ux = x >> 32, uy = y >> 32; uint64_t res; if (ux) { - if (uy) + if (uy) goto overflow; else { uint64_t ly = static_cast<uint32_t> (y), uxly = ux*ly; - if (uxly >> 32) + if (uxly >> 32) goto overflow; uxly <<= 32; // never overflows uint64_t lx = static_cast<uint32_t> (x), lxly = lx*ly; @@ -164,7 +164,7 @@ else if (uy) { uint64_t lx = static_cast<uint32_t> (x), uylx = uy*lx; - if (uylx >> 32) + if (uylx >> 32) goto overflow; uylx <<= 32; // never overflows uint64_t ly = static_cast<uint32_t> (y), lylx = ly*lx; @@ -184,13 +184,13 @@ } template <> -int64_t +int64_t octave_int_arith_base<int64_t, true>::mul (int64_t x, int64_t y) -{ +{ // The signed case is far worse. The problem is that // even if neither integer fits into signed 32-bit range, the result may // still be OK. Uh oh. - + // Essentially, what we do is compute sign, multiply absolute values // (as above) and impose the sign. // FIXME -- can we do something faster if we HAVE_FAST_INT_OPS? @@ -203,12 +203,12 @@ uint64_t res; if (ux) { - if (uy) + if (uy) goto overflow; else { uint64_t ly = static_cast<uint32_t> (usy), uxly = ux*ly; - if (uxly >> 32) + if (uxly >> 32) goto overflow; uxly <<= 32; // never overflows uint64_t lx = static_cast<uint32_t> (usx), lxly = lx*ly; @@ -220,7 +220,7 @@ else if (uy) { uint64_t lx = static_cast<uint32_t> (usx), uylx = uy*lx; - if (uylx >> 32) + if (uylx >> 32) goto overflow; uylx <<= 32; // never overflows uint64_t ly = static_cast<uint32_t> (usy), lylx = ly*lx; @@ -292,14 +292,14 @@ // what we do is to try to convert y/2 and add it twice. Note that if y/2 // overflows, the result must overflow as well, and that y/2 cannot be a // fractional number. - octave_int64 y2 (y / 2); + octave_int64 y2 (y / 2); return (x + y2) + y2; } } DOUBLE_INT_BINOP_DECL (+, int64) -{ - return y + x; +{ + return y + x; } INT_DOUBLE_BINOP_DECL (-, uint64) @@ -310,10 +310,10 @@ DOUBLE_INT_BINOP_DECL (-, uint64) { if (x <= static_cast<double> (octave_uint64::max ())) - return octave_uint64(x) - y; + return octave_uint64(x) - y; else { - // Again a trick to get the corner cases right. Things like + // Again a trick to get the corner cases right. Things like // 3**2**63 - intmax('uint64') should produce the correct result, i.e. // int64(2**63) + 1. const double p2_64 = std::pow (2.0, 64); @@ -334,7 +334,7 @@ DOUBLE_INT_BINOP_DECL (-, int64) { - static const bool twosc = (std::numeric_limits<int64_t>::min () + static const bool twosc = (std::numeric_limits<int64_t>::min () < -std::numeric_limits<int64_t>::max ()); // In case of symmetric integers (not two's complement), this will probably // be eliminated at compile time. @@ -343,7 +343,7 @@ return octave_int64 (x + std::pow(2.0, 63)); } else - return x + (-y); + return x + (-y); } // NOTE: @@ -357,7 +357,7 @@ // Multiplies two unsigned 64-bit ints to get a 128-bit number represented // as four 32-bit words. -static void +static void umul128 (uint64_t x, uint64_t y, uint32_t w[4]) { uint64_t lx = static_cast<uint32_t> (x), ux = x >> 32; @@ -375,7 +375,7 @@ } // Splits a double into bool sign, unsigned 64-bit mantissa and int exponent -static void +static void dblesplit (double x, bool& sign, uint64_t& mtis, int& exp) { sign = x < 0; x = fabs (x); @@ -405,7 +405,7 @@ } else if (y < 0 || xisnan (y) || xisinf (y)) { - return octave_uint64 (x.value () * y); + return octave_uint64 (x.value () * y); } else { @@ -420,7 +420,7 @@ { res += octave_uint64 (dbleget (sign, w[i], e)); e += 32; - } + } return res; } } @@ -440,7 +440,7 @@ } else if (xisnan (y) || xisinf (y)) { - return octave_int64 (x.value () * y); + return octave_int64 (x.value () * y); } else { @@ -456,7 +456,7 @@ { res += octave_int64 (dbleget (sign, w[i], e)); e += 32; - } + } return res; } } @@ -570,10 +570,10 @@ template <class T> octave_int<T> pow (const octave_int<T>& a, const double& b) -{ +{ return ((b >= 0 && b < std::numeric_limits<T>::digits && b == xround (b)) ? pow (a, octave_int<T> (static_cast<T> (b))) - : octave_int<T> (pow (a.double_value (), b))); + : octave_int<T> (pow (a.double_value (), b))); } template <class T> @@ -587,7 +587,7 @@ { return ((b >= 0 && b < std::numeric_limits<T>::digits && b == xround (b)) ? pow (a, octave_int<T> (static_cast<T> (b))) - : octave_int<T> (pow (a.double_value (), static_cast<double> (b)))); + : octave_int<T> (pow (a.double_value (), static_cast<double> (b)))); } #define INSTANTIATE_INTTYPE(T) \