Source: Real.hh


Annotated List
Files
Globals
Hierarchy
Index
// Real - ColdStore interface GNU gmp arbitrary precision floats
// Copyright (C) 1998,1999 Colin McCormack,
// see LICENSE (MD5 f5220f8f599e5e926f37cf32efe3ab68) for terms
// 	$Id: Real_hh.html,v 1.1.1.1 2000/04/09 01:07:51 skeptopotamus Exp $

#ifndef REAL_HH
#define REAL_HH
extern "C" {
#include <gmp2/gmp.h>
}

/** Real - arbitrary precision floats via the gnu gmp library
 */
class Real
    : public Data
{
protected:
    mpf_t _value;

public:
    Real(long value);
    Real(double value = 0.0);
    Real(const Slot &value);
    Real(const char *value);
    Real(const mpz_t &value);
    Real(const mpf_t &value);

    virtual ~Real();

    //operator mpf_t const &() const {return _value;}
    mpf_t const &asGMP() const {return _value;}
    BigInt *asBigInt();
    Integer *asInteger();
    int asint();

    // structural
    virtual Data *clone(void * = 0) const;
    virtual void check(int=0) const;	// check an instance of Data
    
    // object
    virtual bool truth() const;		// the object's truth value
    virtual Slot toconstruct() const;	// constructor args to recreate object
    virtual ostream &dump(ostream& out) const;	// dump the object
    
    static Slot construct(Slot &arg);	// construct from constructor args
    virtual int order(const Slot &arg) const;	// 1,0,-1 depending on order
    virtual bool equal(const Slot &arg) const;	// equality predicate
    
    // arithmetic
    virtual Slot positive();		// monadic `+', absolute value
    virtual Slot negative();		// monadic `-', negative absolute value
    virtual Slot add(const Slot &arg);	// dyadic `+', add
    virtual Slot subtract(const Slot &arg);	// dyadic `-', subtract
    virtual Slot multiply(const Slot &arg);	// dyadic `*', multiply
    virtual Slot divide(const Slot &arg);		// dyadic '/', divide
    virtual Slot modulo(const Slot &arg);		// dyadic '%', modulo

    // local
    static void precision(unsigned long prec);
};

#endif
// Local Variables ***
// c-default-style:gnu ***

Generated by: colin@sharedtech.dhis.org on Sat Nov 6 11:59:24 199.