---
milena/ChangeLog | 4 ++++
milena/mln/value/intsub.hh | 32 +++++++++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6a14cc2..1173826 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,7 @@
+2012-10-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * mln/value/intsub.hh: Add more constructors.
+
2012-10-04 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/value/concept/interval.hh: New. Add value::Interval concept.
diff --git a/milena/mln/value/intsub.hh b/milena/mln/value/intsub.hh
index 897215c..65bef77 100644
--- a/milena/mln/value/intsub.hh
+++ b/milena/mln/value/intsub.hh
@@ -115,12 +115,17 @@ namespace mln
public:
intsub();
intsub(const intsub<n>& rhs);
+ template <unsigned m>
+ intsub(const intsub<m>& rhs);
/// Construct an intsub with value : \p int_part + 1 / \p denominator.
intsub(int int_part, unsigned denominator);
+ intsub(const literal::zero_t&);
intsub(int i);
intsub(float i);
intsub(double i);
+ template <unsigned m>
+ intsub<n>& operator=(const intsub<m>& rhs);
intsub<n>& operator=(const intsub<n>& rhs);
intsub<n>& operator=(int i);
intsub<n>& operator=(float i);
@@ -246,7 +251,7 @@ namespace mln
mult_is_integer(float f, int v)
{
float a = f * v;
- float b = float(unsigned(a));
+ float b = float(int(a));
const float epsilon = 0.00001f;
if (a > b)
@@ -270,6 +275,21 @@ namespace mln
}
template <unsigned n>
+ template <unsigned m>
+ intsub<n>::intsub(const intsub<m>& rhs)
+ {
+ mln_precondition(m < n);
+ this->v_ = rhs.to_enc() * (n / m);
+ }
+
+
+ template <unsigned n>
+ intsub<n>::intsub(const literal::zero_t&)
+ {
+ this->v_ = 0;
+ }
+
+ template <unsigned n>
intsub<n>::intsub(int i)
{
this->v_ = n * i;
@@ -307,6 +327,16 @@ namespace mln
}
template <unsigned n>
+ template <unsigned m>
+ intsub<n>&
+ intsub<n>::operator=(const intsub<m>& rhs)
+ {
+ mln_precondition(m < n);
+ this->v_ = rhs.to_enc() * (n / m);
+ return *this;
+ }
+
+ template <unsigned n>
intsub<n>&
intsub<n>::operator=(int i)
{
--
1.7.2.5