Commit 38f31bc0 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Add conversions from int_u to float and double.

	* mln/convert/from_to.hxx,
	* mln/value/int_u.hh: Here.
parent 85d4bb72
2010-11-15 Guillaume Lazzara <z@lrde.epita.fr>
Add conversions from int_u to float and double.
* mln/convert/from_to.hxx,
* mln/value/int_u.hh: Here.
2010-11-15 Guillaume Lazzara <z@lrde.epita.fr> 2010-11-15 Guillaume Lazzara <z@lrde.epita.fr>
   
* mln/convert/from_to.hh: Make use of value::cast for conversions * mln/convert/from_to.hh: Make use of value::cast for conversions
// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) // Copyright (C) 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
// //
// This file is part of Olena. // This file is part of Olena.
// //
...@@ -202,6 +203,14 @@ namespace mln ...@@ -202,6 +203,14 @@ namespace mln
void void
from_to_(const value::int_u<n>& from, bool& to_); from_to_(const value::int_u<n>& from, bool& to_);
// int_u -> float
template <unsigned n>
void from_to_(const value::int_u<n>& from, float& to_);
// int_u -> double
template <unsigned n>
void from_to_(const value::int_u<n>& from, double& to_);
// label -> int_u. // label -> int_u.
template <unsigned n> template <unsigned n>
void void
......
...@@ -128,6 +128,18 @@ namespace mln ...@@ -128,6 +128,18 @@ namespace mln
from_to_(const value::int_u<n>& from, bool& to_); from_to_(const value::int_u<n>& from, bool& to_);
// int_u -> float.
template <unsigned n>
void
from_to_(const value::int_u<n>& from, float& to_);
// int_u -> double.
template <unsigned n>
void
from_to_(const value::int_u<n>& from, double& to_);
} // end of namespace mln::convert::over_load } // end of namespace mln::convert::over_load
} // end of namespace mln::convert } // end of namespace mln::convert
...@@ -232,6 +244,24 @@ namespace mln ...@@ -232,6 +244,24 @@ namespace mln
to_ = (from != 0u); to_ = (from != 0u);
} }
// int_u -> float.
template <unsigned n>
inline
void
from_to_(const value::int_u<n>& from, float& to_)
{
to_ = static_cast<float>(from);
}
// int_u -> double.
template <unsigned n>
inline
void
from_to_(const value::int_u<n>& from, double& to_)
{
to_ = static_cast<double>(from);
}
} // end of namespace mln::convert::over_load } // end of namespace mln::convert::over_load
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment