27 #ifndef MLN_CONVERT_IMPL_FROM_FLOAT_TO_VALUE_HH
28 # define MLN_CONVERT_IMPL_FROM_FLOAT_TO_VALUE_HH
37 # include <mln/value/concept/integer.hh>
38 # include <mln/value/concept/floating.hh>
39 # include <mln/core/concept/value.hh>
40 # include <mln/math/round.hh>
50 void from_to_(
const float& from, Value<V>& to);
53 void from_to_(
const float& from,
unsigned& to);
56 void from_to_(
const float& from,
int& to);
59 void from_to_(
const float& from,
short& to);
62 # ifndef MLN_INCLUDE_ONLY
75 from_float_to_value(
const float& from,
78 exact(to) = math::round<V>(from);
86 from_float_to_value(
const float& from,
98 from_float_to_value(
const float& from,
103 mlc_abort(V)::check();
112 template <
typename V>
115 from_float_to_value_dispatch(
const float& from, Value<V>&
to)
117 impl::from_float_to_value(from,
exact(to));
126 template <
typename V>
129 from_to_(
const float& from, Value<V>& to)
131 convert::internal::from_float_to_value_dispatch(from, to);
137 from_to_(
const float& from,
unsigned& to)
139 mln_precondition(from >= 0);
140 to = math::round<unsigned>(from);
146 from_to_(
const float& from,
int& to)
148 to = math::round<int>(from);
154 from_to_(
const float& from,
short& to)
156 to = math::round<short>(from);
160 # endif // ! MLN_INCLUDE_ONLY
165 #endif // ! MLN_CONVERT_IMPL_FROM_FLOAT_TO_VALUE_HH