aboutsummaryrefslogtreecommitdiff
path: root/src/core/scriptshared.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/scriptshared.hpp')
-rw-r--r--src/core/scriptshared.hpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/core/scriptshared.hpp b/src/core/scriptshared.hpp
index 01d423a..65c02bc 100644
--- a/src/core/scriptshared.hpp
+++ b/src/core/scriptshared.hpp
@@ -3,28 +3,28 @@
#include <cmath>
#define eps 1e-6
typedef union _Udata{//data union
- int i;float r;unsigned long d;
+ int i;double r;unsigned long d;
_Udata(){d=0;}
}Udata;
typedef struct _Idata{//data union, with type tag and operators
_Udata D;
- int type;//0=int, 1=float
+ int type;//0=int, 1=double
_Idata(){D.d=0;type=0;}
_Idata(int _type,int _data)
- {type=_type;if(type==0)D.i=_data;else D.r=(float)_data;}
- float &r(){return D.r;}
+ {type=_type;if(type==0)D.i=_data;else D.r=(double)_data;}
+ double &r(){return D.r;}
int &i(){return D.i;}
unsigned long &d(){return D.d;}
_Idata operator =(_Idata r)
{
- if(type==1&&r.type==0)this->r()=(float)r.i();
+ if(type==1&&r.type==0)this->r()=(double)r.i();
else if(type==0&&r.type==1)this->i()=(int)r.r();
else this->d()=r.d();
return *this;
}
_Idata operator +=(_Idata r)
{
- if(type==1&&r.type==0)this->r()+=(float)r.i();
+ if(type==1&&r.type==0)this->r()+=(double)r.i();
if(type==0&&r.type==1)this->i()+=(int)r.r();
if(type==0&&r.type==0)this->i()+=r.i();
if(type==1&&r.type==1)this->r()+=r.r();
@@ -32,7 +32,7 @@ typedef struct _Idata{//data union, with type tag and operators
}
_Idata operator -=(_Idata r)
{
- if(type==1&&r.type==0)this->r()-=(float)r.i();
+ if(type==1&&r.type==0)this->r()-=(double)r.i();
if(type==0&&r.type==1)this->i()-=(int)r.r();
if(type==0&&r.type==0)this->i()-=r.i();
if(type==1&&r.type==1)this->r()-=r.r();
@@ -40,7 +40,7 @@ typedef struct _Idata{//data union, with type tag and operators
}
_Idata operator *=(_Idata r)
{
- if(type==1&&r.type==0)this->r()*=(float)r.i();
+ if(type==1&&r.type==0)this->r()*=(double)r.i();
if(type==0&&r.type==1)this->i()*=(int)r.r();
if(type==0&&r.type==0)this->i()*=r.i();
if(type==1&&r.type==1)this->r()*=r.r();
@@ -48,7 +48,7 @@ typedef struct _Idata{//data union, with type tag and operators
}
_Idata operator /=(_Idata r)
{
- if(type==1&&r.type==0)this->r()/=(float)r.i();
+ if(type==1&&r.type==0)this->r()/=(double)r.i();
if(type==0&&r.type==1)this->i()/=(int)r.r();
if(type==0&&r.type==0)this->i()/=r.i();
if(type==1&&r.type==1)this->r()/=r.r();