Mercurial > hg > octave-nkf
changeset 4943:1a499d0c58f5
[project @ 2004-08-31 00:51:31 by jwe]
author | jwe |
---|---|
date | Tue, 31 Aug 2004 00:51:31 +0000 |
parents | a0f2839f6ac8 |
children | 44046bbaa52c |
files | liboctave/ChangeLog liboctave/oct-inttypes.h |
diffstat | 2 files changed, 107 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,50 @@ +2004-08-30 John W. Eaton <jwe@octave.org> + + * oct-inttypes.h (octave_int_fit_to_range): Use template + specializations to avoid warnings about signed/unsigned comparisons. + +2004-08-28 John W. Eaton <jwe@octave.org> + + * 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 <jwe@octave.org> + + * 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 <dbateman@free.fr> * chNDArray.cc (concat): Check whether matrix to be inserted is
--- a/liboctave/oct-inttypes.h +++ b/liboctave/oct-inttypes.h @@ -135,8 +135,65 @@ return (x > mx ? mx : (x < mn ? mn : static_cast<T2> (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<T1, T2> (const T1& x, const T2&, const T2& mx) \ + { \ + return x > static_cast<TC> (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<T1, T2> (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<T>::min (), std::numeric_limits<T>::max ()) + octave_int_fit_to_range (r, \ + std::numeric_limits<T>::min (), \ + std::numeric_limits<T>::max ()) #define OCTAVE_INT_MIN_VAL2(T1, T2) \ std::numeric_limits<typename octave_int_binop_traits<T1, T2>::TR>::min () @@ -155,6 +212,8 @@ { public: + typedef T val_type; + octave_int (void) : ival () { } template <class U>