Re: [AD] C++ fix math

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> The problem is, allegro's fix class will somehow auto-convert the
> float and use the fixed float.. (as i said, i'm not sure how it
> works)

Here's the patch I'm going to check in modulo no new argument against it:

--- /home/Eric/cvsroot/allegro/include/allegro/fix.h Tue Jul 23 01:25:38 2002
+++ allegro/include/allegro/fix.h Sat Aug 10 15:45:08 2002
@@ -29,14 +29,14 @@
 public:
    fixed v;
 
-   fix() : v(0)                              { }
-   fix(const fix &x) : v(x.v)                { }
-   fix(const int x) : v(itofix(x))           { }
-   fix(const long x) : v(itofix(x))          { }
-   fix(const unsigned int x) : v(itofix(x))  { }
-   fix(const unsigned long x) : v(itofix(x)) { }
-   fix(const float x) : v(ftofix(x))         { }
-   fix(const double x) : v(ftofix(x))        { }
+   fix() : v(0)                                       {}
+   fix(const fix &x) : v(x.v)                         {}
+   explicit fix(const int x) : v(itofix(x))           {}
+   explicit fix(const long x) : v(itofix(x))          {}
+   explicit fix(const unsigned int x) : v(itofix(x))  {}
+   explicit fix(const unsigned long x) : v(itofix(x)) {}
+   explicit fix(const float x) : v(ftofix(x))         {}
+   explicit fix(const double x) : v(ftofix(x))        {}
 
    operator int() const                      { return fixtoi(v); }
    operator long() const                     { return fixtoi(v); }
--- /home/Eric/cvsroot/allegro/docs/src/api._tx Thu Jul 11 09:52:40 2002
+++ allegro/docs/src/api._tx Sat Aug 10 15:39:50 2002
@@ -73,5 +73,8 @@
    The preprocessor symbol USE_CONSOLE is deprecated. Define instead the
    symbol ALLEGRO_USE_CONSOLE prior to including Allegro headers in order
    to set up Allegro for building a console application.
+<li>
+   The constructors of the fix class from integer and floating point values
+   are now explicit.
 </ul>
 

- Eric



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/