- Code: Select all
`DynamicAny any("0");`

float f = any; // an "Out of range: Value to small" exception occurs here

and also

- Code: Select all
`double d = 0;`

DynamicAny any(d)

float f = any; // an "Out of range: Value to small" exception occurs here

It looks like the problem is occurring in the DynamicAnyHolder::checkLowerLimit() method.

- Code: Select all
`template <typename F, typename T>`

void checkLowerLimit(const F& from, T&) const

{

if (from < std::numeric_limits<T>::min())

throw RangeException("Value too small.");

}

the std::numeric_limits<T>::min() function behaves differently for integer and floating point types. For integer types it returns the min value as most would expect, but for floating point types it returns the smallest positive number the type can represent. I don't know the history behind this, but I guess the solution would be something like this:

- Code: Select all
`template <typename F, typename T>`

void checkLowerLimit(const F& from, T&) const

{

if (std::numeric_limits<T>::is_integer)

{

if (from < std::numeric_limits<T>::min())

throw RangeException("Value too small.");

}

else

{

// if (from < -std::numeric_limits<T>::min()) edited 03/30/09

if (from < -std::numeric_limits<T>::max())

throw RangeException("Value too small.");

}

}

Probably a cleaner way, but that's what comes to mind.

-WITTROCK