# HG changeset patch # User jwe # Date 1093913491 0 # Node ID 1a499d0c58f530aacc00644d2ba185fe3c2a9b41 # Parent a0f2839f6ac83c50e92383f050f168e1378e4ce4 [project @ 2004-08-31 00:51:31 by jwe] diff -r a0f2839f6ac8 -r 1a499d0c58f5 liboctave/ChangeLog --- a/liboctave/ChangeLog Sat Aug 28 01:29:39 2004 +0000 +++ b/liboctave/ChangeLog Tue Aug 31 00:51:31 2004 +0000 @@ -1,3 +1,50 @@ +2004-08-30 John W. Eaton + + * oct-inttypes.h (octave_int_fit_to_range): Use template + specializations to avoid warnings about signed/unsigned comparisons. + +2004-08-28 John W. Eaton + + * data-conv.cc (do_float_format_conversion (unsigned char *, + size_t, int, oct_mach_info::float_format)): New function. + (GET_SIZED_INT_TYPE): New macro. + (string_to_data_type): Use it to return sized types corresponding + to Octave array data types. + (strip_spaces): New function. + (do_double_format_conversion, do_float_format_conversion): Pass + from_fmt and to_fmt. Don't always assume the to_fmt is the native + float format. + (do_double_format_conversion, + IEEE_big_double_to_IEEE_little_double, + VAX_D_double_to_IEEE_little_double, + VAX_G_double_to_IEEE_little_double, Cray_to_IEEE_little_double, + IEEE_little_double_to_IEEE_big_double, + VAX_D_double_to_IEEE_big_double, VAX_G_double_to_IEEE_big_double, + Cray_to_IEEE_big_double, IEEE_little_double_to_VAX_D_double, + IEEE_big_double_to_VAX_D_double, VAX_G_double_to_VAX_D_double, + Cray_to_VAX_D_double, IEEE_little_double_to_VAX_G_double, + IEEE_big_double_to_VAX_G_double, VAX_D_double_to_VAX_G_double, + Cray_to_VAX_G_double): + Pass data as void*, not double*. + (do_float_format_conversion, IEEE_big_float_to_IEEE_little_float, + VAX_D_float_to_IEEE_little_float, + VAX_G_float_to_IEEE_little_float, Cray_to_IEEE_little_float, + IEEE_little_float_to_IEEE_big_float, + VAX_D_float_to_IEEE_big_float, VAX_G_float_to_IEEE_big_float, + Cray_to_IEEE_big_float, IEEE_little_float_to_VAX_D_float, + IEEE_big_float_to_VAX_D_float, VAX_G_float_to_VAX_D_float, + Cray_to_VAX_D_float, IEEE_little_float_to_VAX_G_float, + IEEE_big_float_to_VAX_G_float, VAX_D_float_to_VAX_G_float, + Cray_to_VAX_G_float): + Pass data as void*, not float*. + +2004-08-27 John W. Eaton + + * byte-swap.h (swap_bytes): New template versions, with + specializations. + (swap_2_bytes, swap_4_bytes, swap_8_bytes): Delete. + Change all uses. + 2004-08-24 David Bateman * chNDArray.cc (concat): Check whether matrix to be inserted is diff -r a0f2839f6ac8 -r 1a499d0c58f5 liboctave/oct-inttypes.h --- a/liboctave/oct-inttypes.h Sat Aug 28 01:29:39 2004 +0000 +++ b/liboctave/oct-inttypes.h Tue Aug 31 00:51:31 2004 +0000 @@ -135,8 +135,65 @@ return (x > mx ? mx : (x < mn ? mn : static_cast (x))); } +// If X is unsigned and the new type is signed, then we only have to +// check the upper limit, but we should cast the maximum value of the +// new type to an unsigned type before performing the comparison. +// This should always be OK because the maximum value should always be +// positive. + +#define US_S_FTR(T1, T2, TC) \ + template <> \ + inline T2 \ + octave_int_fit_to_range (const T1& x, const T2&, const T2& mx) \ + { \ + return x > static_cast (mx) ? mx : x; \ + } + +#define US_S_FTR_FCNS(T) \ + US_S_FTR(T, char, unsigned char) \ + US_S_FTR(T, signed char, unsigned char) \ + US_S_FTR(T, short, unsigned short) \ + US_S_FTR(T, int, unsigned int) \ + US_S_FTR(T, long, unsigned long) \ + US_S_FTR(T, long long, unsigned long long) + +US_S_FTR_FCNS (unsigned char) +US_S_FTR_FCNS (unsigned short) +US_S_FTR_FCNS (unsigned int) +US_S_FTR_FCNS (unsigned long) +US_S_FTR_FCNS (unsigned long long) + +// If X is signed and the new type is unsigned, then we only have to +// check the lower limit (which will always be 0 for an unsigned +// type). The upper limit will be enforced correctly by converting to +// the new type, even if the type of X is wider than the new type. + +#define S_US_FTR(T1, T2) \ + template <> \ + inline T2 \ + octave_int_fit_to_range (const T1& x, const T2&, const T2&) \ + { \ + return x < 0 ? 0 : x; \ + } + +#define S_US_FTR_FCNS(T) \ + S_US_FTR(T, unsigned char) \ + S_US_FTR(T, unsigned short) \ + S_US_FTR(T, unsigned int) \ + S_US_FTR(T, unsigned long) \ + S_US_FTR(T, unsigned long long) + +S_US_FTR_FCNS (char) +S_US_FTR_FCNS (signed char) +S_US_FTR_FCNS (short) +S_US_FTR_FCNS (int) +S_US_FTR_FCNS (long) +S_US_FTR_FCNS (long long) + #define OCTAVE_INT_FIT_TO_RANGE(r, T) \ - octave_int_fit_to_range (r, std::numeric_limits::min (), std::numeric_limits::max ()) + octave_int_fit_to_range (r, \ + std::numeric_limits::min (), \ + std::numeric_limits::max ()) #define OCTAVE_INT_MIN_VAL2(T1, T2) \ std::numeric_limits::TR>::min () @@ -155,6 +212,8 @@ { public: + typedef T val_type; + octave_int (void) : ival () { } template