]> www.ginac.de Git - ginac.git/blobdiff - ginac/numeric.h
- removed manual basepointer-fiddling in construct-on-first-use objects
[ginac.git] / ginac / numeric.h
index 4c7fd0b33162ab7572f8de42a75e7ee0d3747e83..09f15233f7d59a4bca08bd2fd9dcb7d90cefbc17 100644 (file)
@@ -39,8 +39,6 @@ namespace cln { class cl_N; }
 
 namespace GiNaC {
 
-#define HASHVALUE_NUMERIC 0x80000001U
-
 /** This class is used to instantiate a global singleton object Digits
  *  which behaves just like Maple's Digits.  We need an object rather 
  *  than a dumber basic type since as a side-effect we let it change
@@ -74,15 +72,15 @@ class numeric : public basic
        
        // other ctors
 public:
-       explicit numeric(int i);
-       explicit numeric(unsigned int i);
-       explicit numeric(long i);
-       explicit numeric(unsigned long i);
-       explicit numeric(long numer, long denom);
-       explicit numeric(double d);
-       explicit numeric(const char *);
+       numeric(int i);
+       numeric(unsigned int i);
+       numeric(long i);
+       numeric(unsigned long i);
+       numeric(long numer, long denom);
+       numeric(double d);
+       numeric(const char *);
        
-       // functions overriding virtual functions from bases classes
+       // functions overriding virtual functions from base classes
 public:
        void print(const print_context & c, unsigned level = 0) const;
        unsigned precedence(void) const {return 30;}
@@ -287,11 +285,20 @@ ex CatalanEvalf(void);
 
 
 // utility functions
+
+/** Return the numeric object handled by an ex.  Deprecated: use ex_to<numeric>().
+ *  This is unsafe: you need to check the type first. */
 inline const numeric &ex_to_numeric(const ex &e)
 {
        return static_cast<const numeric &>(*e.bp);
 }
 
+/** Specialization of is_exactly_a<numeric>(obj) for numeric objects. */
+template<> inline bool is_exactly_a<numeric>(const basic & obj)
+{
+       return obj.tinfo()==TINFO_numeric;
+}
+
 } // namespace GiNaC
 
 #ifdef __MAKECINT__