mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-30 13:47:10 +01:00
[SF 2715031] DynamicAny double to float conversion
This commit is contained in:
@@ -212,11 +212,16 @@ protected:
|
|||||||
poco_static_assert (std::numeric_limits<T>::is_signed);
|
poco_static_assert (std::numeric_limits<T>::is_signed);
|
||||||
|
|
||||||
if (std::numeric_limits<F>::is_integer)
|
if (std::numeric_limits<F>::is_integer)
|
||||||
|
{
|
||||||
checkUpperLimit<F,T>(from);
|
checkUpperLimit<F,T>(from);
|
||||||
|
checkLowerLimit<F,T>(from);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
checkUpperLimitFloat<F,T>(from);
|
checkUpperLimitFloat<F,T>(from);
|
||||||
|
checkLowerLimitFloat<F,T>(from);
|
||||||
checkLowerLimit<F,T>(from);
|
}
|
||||||
|
|
||||||
to = static_cast<T>(from);
|
to = static_cast<T>(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,6 +318,13 @@ private:
|
|||||||
throw RangeException("Value too large.");
|
throw RangeException("Value too large.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename F, typename T>
|
||||||
|
void checkLowerLimitFloat(const F& from) const
|
||||||
|
{
|
||||||
|
if (from < -std::numeric_limits<T>::max())
|
||||||
|
throw RangeException("Value too small.");
|
||||||
|
}
|
||||||
|
|
||||||
template <typename F, typename T>
|
template <typename F, typename T>
|
||||||
void checkLowerLimit(const F& from) const
|
void checkLowerLimit(const F& from) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -934,6 +934,9 @@ void VarTest::testChar()
|
|||||||
|
|
||||||
void VarTest::testFloat()
|
void VarTest::testFloat()
|
||||||
{
|
{
|
||||||
|
Var any("0");
|
||||||
|
float f = any;
|
||||||
|
|
||||||
float src = 32.0f;
|
float src = 32.0f;
|
||||||
Var a1 = src;
|
Var a1 = src;
|
||||||
|
|
||||||
@@ -1022,6 +1025,10 @@ void VarTest::testFloat()
|
|||||||
|
|
||||||
void VarTest::testDouble()
|
void VarTest::testDouble()
|
||||||
{
|
{
|
||||||
|
double d = 0;
|
||||||
|
Var v(d);
|
||||||
|
float f = v;
|
||||||
|
|
||||||
double src = 32.0;
|
double src = 32.0;
|
||||||
Var a1 = src;
|
Var a1 = src;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user