Opened 14 years ago

Last modified 14 years ago

#2473 new Bugs

unsigned integers going into interval of doubles get wrongly negated

Reported by: David Monniaux <David.Monniaux@…> Owned by: Boris Gubenko
Milestone: Boost 1.38.0 Component: interval
Version: Boost Development Trunk Severity: Problem
Keywords: unsigned Cc:

Description

interval<double> x(1U) gets wrong lower bound (-232+1 instead of 1). Apparently, the unary - operation is performed on the unsigned int instead of the double.

Workaround: manually cast to double before creating the interval.

Attachments (1)

bug_unsigned_boost.cc (317 bytes ) - added by David Monniaux <David.Monniaux@…> 14 years ago.
very short example exhibiting bug

Download all attachments as: .zip

Change History (4)

by David Monniaux <David.Monniaux@…>, 14 years ago

Attachment: bug_unsigned_boost.cc added

very short example exhibiting bug

comment:1 by Gunter, 14 years ago

This problem causes the failure of test7 of ublas. I'd appreciate if someone finds time to fix it.

comment:2 by Gunter, 14 years ago

I tracked the source of the problem down to rounded_arith.hpp:93 where (-v) is computed although the type of v is and unsigned integer.

Additionally I wonder why the constructor of interval<T> is template <T1, T2> interval(T1, T2) and not simply interval(T,T). The latter constructor would enforce the conversion to the correct type and prevent the shown bug.

comment:3 by Gunter, 14 years ago

(In [52147]) ublas/doc/samples/ex_triangular.cpp: added new example ublas/doc/samples/Jamfile.v2: added build section for ex_triangular ublas/doc/container_concept.htm: fixed wrong description of array_type ublas/doc/triangular.htm: fixed lower/upper confusion and added link to ex_triangular

ublas/test/test_lu.cpp: added unit test for LU decomposition ublas/test/triangular_access.cpp: added unit test for accessing triangular/symmetric matrices ublas/test/triangular_layout.cpp: added unit test for testing storage layout of triangular/symmetric matrices ublas/test/common/testhelper.hpp: support routines for new unit tests

ublas/test/CMakeLists.txt: added new tests (still experimental) test_lu, triangular_access. triangular_layout

ublas/test/Jamfile.v2:

added new tests (still experimental) test_lu, triangular_access. triangular_layout disabled broken test7 (maybe a fix of boost::interval is needed, see #2473)

ublas/test/test71.cpp, ublas/test/test73.cpp, ublas/test/test7.cpp:

added first fixes to support boost::interval as scalar type

ublas/test/common/init.hpp:

initialize all matrices/vectors with floats instead of (unsigned) ints this helps to fix broken test7 for boost::interval

Note: See TracTickets for help on using tickets.