*** empty log message ***
git-svn-id: svn://10.65.10.50/trunk@18 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
65d9f0ec14
commit
3f5ce20380
@ -77,25 +77,30 @@ class TSpreadsheet:public TWindow
|
||||
{
|
||||
return _mask;
|
||||
}
|
||||
|
||||
int items () const
|
||||
{
|
||||
return _str.items ();
|
||||
}
|
||||
|
||||
int columns () const
|
||||
{
|
||||
return _columns;
|
||||
}
|
||||
|
||||
bool dirty () const
|
||||
{
|
||||
return _dirty;
|
||||
}
|
||||
|
||||
void set_notify (SPREADSHEET_NOTIFY n)
|
||||
{
|
||||
_notify = n;
|
||||
}
|
||||
|
||||
void set_dirty (bool spork = TRUE)
|
||||
{_dirty = spork;
|
||||
{
|
||||
_dirty = spork;
|
||||
}
|
||||
|
||||
TSpreadsheet (short x, short y, short dx, short dy, const char *maskname, int maskno,
|
||||
@ -209,7 +214,8 @@ TSpreadsheet ::TSpreadsheet (short x, short y, short dx, short dy,
|
||||
{
|
||||
const int cid = FIRST_FIELD + i; // Column & Field ID
|
||||
const TMask_field * f = field (cid); // Field on mask
|
||||
const int w = width[i] + (f->has_query ()? 2 : 0); // Column width
|
||||
const int w = width[i] + (f->has_query ()? 2 : 0); // Column
|
||||
// width
|
||||
|
||||
long flags = XI_ATR_EDITMENU | XI_ATR_AUTOSCROLL;
|
||||
if (f->class_id () == CLASS_REAL_FIELD) flags |= XI_ATR_RJUST;
|
||||
|
File diff suppressed because it is too large
Load Diff
321
include/real.cpp
321
include/real.cpp
@ -2,7 +2,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <gm.h>
|
||||
|
||||
extern "C" { double pow(double, double); } // Should be #include <math.h>
|
||||
extern "C"
|
||||
{
|
||||
double pow (double, double);
|
||||
} // Should be #include <math.h>
|
||||
|
||||
#include <strings.h>
|
||||
#include <real.h>
|
||||
@ -12,31 +15,41 @@ HIDDEN char __string[80];
|
||||
const real ZERO (0.0);
|
||||
|
||||
real ::real ()
|
||||
{ dzero(ptr()); }
|
||||
{
|
||||
dzero (ptr ());
|
||||
}
|
||||
|
||||
real ::real (const real & b)
|
||||
{ dcpy(ptr(), b.ptr()); }
|
||||
{
|
||||
dcpy (ptr (), b.ptr ());
|
||||
}
|
||||
|
||||
real ::real (double a)
|
||||
{
|
||||
dftodr (ptr (), a, 9); // Round the number (1.0 is NOT 0.999999999)
|
||||
|
||||
deltrz (ptr (), ptr ()); // Delete Trailing zeroes
|
||||
|
||||
}
|
||||
|
||||
char* real::eng2ita(char* s)
|
||||
char *real ::
|
||||
eng2ita (char *s)
|
||||
{
|
||||
if (s)
|
||||
{
|
||||
char *dot = strchr (s, '.');
|
||||
if (dot) *dot = ',';
|
||||
if (dot)
|
||||
*dot = ',';
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
char* real::ita2eng(const char* s)
|
||||
char *real ::
|
||||
ita2eng (const char *s)
|
||||
{
|
||||
int j = 0;
|
||||
if (s) for (int i = 0; s[i]; i++)
|
||||
if (s)
|
||||
for (int i = 0; s[i]; i++)
|
||||
{
|
||||
switch (s[i])
|
||||
{
|
||||
@ -55,12 +68,15 @@ char* real::ita2eng(const char* s)
|
||||
return __string;
|
||||
}
|
||||
|
||||
bool real::is_real(const char* s)
|
||||
bool real ::
|
||||
is_real (const char *s)
|
||||
{
|
||||
bool ok = FALSE;
|
||||
if (s)
|
||||
{
|
||||
while(*s == ' ') s++; // Remove leading spaces before atod
|
||||
while (*s == ' ')
|
||||
s++; // Remove leading spaces before atod
|
||||
|
||||
ok = atod (__tmp_real.ptr (), (char *) s) != GM_NULL;
|
||||
}
|
||||
return ok;
|
||||
@ -69,7 +85,8 @@ bool real::is_real(const char* s)
|
||||
real ::real (const char *s)
|
||||
{
|
||||
if (s)
|
||||
while(*s == ' ') s++; // Remove leading spaces before atod
|
||||
while (*s == ' ')
|
||||
s++; // Remove leading spaces before atod
|
||||
|
||||
if (s && *s)
|
||||
atod (ptr (), (char *) s);
|
||||
@ -131,91 +148,106 @@ real& real::operator /=(const real& b)
|
||||
return *this;
|
||||
}
|
||||
|
||||
TObject* real::dup() const
|
||||
{ return new real(*this); }
|
||||
TObject *real ::
|
||||
dup ()
|
||||
const
|
||||
{
|
||||
return new real (*this);
|
||||
}
|
||||
|
||||
bool real::is_zero() const
|
||||
bool real ::is_zero ()
|
||||
const
|
||||
{
|
||||
return diszero (ptr ());
|
||||
}
|
||||
|
||||
int real::sign() const
|
||||
{ return dsign(ptr()); }
|
||||
int real ::sign ()
|
||||
const
|
||||
{
|
||||
return dsign (ptr ());
|
||||
}
|
||||
|
||||
|
||||
real real::operator -() const
|
||||
real real ::operator - ()
|
||||
const
|
||||
{
|
||||
real n;
|
||||
dchgs (n.ptr (), ptr ());
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
int real::integer() const
|
||||
{ return dtoi(ptr()); }
|
||||
|
||||
int real ::integer ()
|
||||
const
|
||||
{
|
||||
return dtoi (ptr ());
|
||||
}
|
||||
|
||||
// Certified 91%
|
||||
char* real::string(int len, int dec, char pad) const
|
||||
char *real ::string (int len, int dec, char pad)
|
||||
const
|
||||
{
|
||||
__tmp_real = *this;
|
||||
if (dec != UNDEFINED) __tmp_real.round(dec);
|
||||
else deltrz(__tmp_real.ptr(), __tmp_real.ptr());
|
||||
if (dec != UNDEFINED)
|
||||
__tmp_real.round (dec);
|
||||
else
|
||||
deltrz (__tmp_real.ptr (), __tmp_real.ptr ());
|
||||
|
||||
// if (len == 0)
|
||||
dtoa (__string, __tmp_real.ptr ());
|
||||
/*
|
||||
else
|
||||
{
|
||||
char f[16];
|
||||
if (dec == UNDEFINED) sprintf(f, "%%%dt", len);
|
||||
else
|
||||
sprintf(f, "%%%d.%dt", len, dec);
|
||||
dsprintf(__string, f, __tmp_real.ptr());
|
||||
}
|
||||
|
||||
if (dec <= 0 || dec == UNDEFINED) // Toglie una eventuale parte decimale .00
|
||||
{
|
||||
if (dot)
|
||||
{
|
||||
for (const char* z = dot + 1; *z; z++)
|
||||
if (*z != '0') break;
|
||||
if (!*z) *dot = '\0';
|
||||
}
|
||||
}
|
||||
* else
|
||||
* {
|
||||
* char f[16];
|
||||
* if (dec == UNDEFINED) sprintf(f, "%%%dt", len);
|
||||
* else
|
||||
* sprintf(f, "%%%d.%dt", len, dec);
|
||||
* dsprintf(__string, f, __tmp_real.ptr());
|
||||
* }
|
||||
*
|
||||
* if (dec <= 0 || dec == UNDEFINED) // Toglie una eventuale parte decimale .00
|
||||
* {
|
||||
* if (dot)
|
||||
* {
|
||||
* for (const char* z = dot + 1; *z; z++)
|
||||
* if (*z != '0') break;
|
||||
* if (!*z) *dot = '\0';
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
int lun = strlen (__string);
|
||||
|
||||
/*
|
||||
char* dot = strchr(__string, '.');
|
||||
|
||||
int d = dot ? strlen(dot+1) : 0; // Decimals already there
|
||||
|
||||
if (d < dec)
|
||||
{
|
||||
if (dot == NULL) __string[lun++] = '.');
|
||||
for (;d < dec; d++) __string[lun++] = '0';
|
||||
__string[lun] = '\0';
|
||||
} else
|
||||
if (dec >= 0 && d > dec)
|
||||
{
|
||||
*(dot+dec+(dec>0)) = '\0';
|
||||
lun = strlen(__string);
|
||||
}
|
||||
* char* dot = strchr(__string, '.');
|
||||
*
|
||||
* int d = dot ? strlen(dot+1) : 0; // Decimals already there
|
||||
*
|
||||
* if (d < dec)
|
||||
* {
|
||||
* if (dot == NULL) __string[lun++] = '.');
|
||||
* for (;d < dec; d++) __string[lun++] = '0';
|
||||
* __string[lun] = '\0';
|
||||
* } else
|
||||
* if (dec >= 0 && d > dec)
|
||||
* {
|
||||
* *(dot+dec+(dec>0)) = '\0';
|
||||
* lun = strlen(__string);
|
||||
* }
|
||||
*/
|
||||
if (lun < len)
|
||||
{
|
||||
const int delta = len - lun;
|
||||
for (int i = lun; i >= 0; i--)
|
||||
__string[i + delta] = __string[i];
|
||||
for (i = 0; i < delta; i++) __string[i] = pad;
|
||||
for (i = 0; i < delta; i++)
|
||||
__string[i] = pad;
|
||||
}
|
||||
|
||||
return __string;
|
||||
}
|
||||
|
||||
// Certified 99%
|
||||
char* real::stringa(int len, int dec, char pad) const
|
||||
char *real ::
|
||||
stringa (int len, int dec, char pad)
|
||||
const
|
||||
|
||||
{
|
||||
string (len, dec, pad);
|
||||
@ -224,27 +256,32 @@ char* real::stringa(int len, int dec, char pad) const
|
||||
return __string;
|
||||
}
|
||||
|
||||
|
||||
// Certified 75%
|
||||
char* real::literals() const
|
||||
char *real ::literals ()
|
||||
const
|
||||
{
|
||||
const char* primi20[] = { "", "uno","due","tre","quattro",
|
||||
const char *primi20[] =
|
||||
{"", "uno", "due", "tre", "quattro",
|
||||
"cinque", "sei", "sette", "otto",
|
||||
"nove", "dieci", "undici", "dodici",
|
||||
"tredici", "quattordici", "quindici", "sedici"
|
||||
"diciassette", "diciotto", "diciannove"};
|
||||
const char* decine[] = { "zero", "dieci", "venti", "trenta", "quaranta",
|
||||
const char *decine[] =
|
||||
{"zero", "dieci", "venti", "trenta", "quaranta",
|
||||
"cinquanta", "sessanta", "settanta", "ottanta",
|
||||
"novanta", "cento"};
|
||||
const char* uni[] = { "uno", "mille", "unmilione", "unmiliardo" };
|
||||
const char *uni[] =
|
||||
{"uno", "mille", "unmilione", "unmiliardo"};
|
||||
|
||||
const char* potenze[] = { "", "mila", "milioni", "miliardi" };
|
||||
const char *potenze[] =
|
||||
{"", "mila", "milioni", "miliardi"};
|
||||
|
||||
__tmp_real = *this;
|
||||
__tmp_real.round (0);
|
||||
TString r (__tmp_real.string (0, 0));
|
||||
const bool negativo = r[0] == '-';
|
||||
if (negativo) r.ltrim(1);
|
||||
if (negativo)
|
||||
r.ltrim (1);
|
||||
|
||||
TFixed_string risultato (__string, 80);
|
||||
risultato.cut (0);
|
||||
@ -254,9 +291,11 @@ char* real::literals() const
|
||||
for (int migliaia = 0;; migliaia++)
|
||||
{
|
||||
int v = r.len () - 3;
|
||||
if (v < -2) break;
|
||||
if (v < -2)
|
||||
break;
|
||||
|
||||
if (v < 0) v = 0;
|
||||
if (v < 0)
|
||||
v = 0;
|
||||
const int val = atoi (&r[v]);
|
||||
r.cut (v); // Elimina ultimi 3 caratteri
|
||||
|
||||
@ -264,8 +303,10 @@ char* real::literals() const
|
||||
if (v >= 100)
|
||||
{
|
||||
const int c = v / 100;
|
||||
if (c > 1) centinaia = primi20[c];
|
||||
else centinaia.cut(0);
|
||||
if (c > 1)
|
||||
centinaia = primi20[c];
|
||||
else
|
||||
centinaia.cut (0);
|
||||
v -= c * 100;
|
||||
centinaia << "cento";
|
||||
}
|
||||
@ -278,23 +319,28 @@ char* real::literals() const
|
||||
if (v != 1)
|
||||
{
|
||||
centinaia << primi20[v] << potenze[migliaia];
|
||||
} else
|
||||
if (val > 1)
|
||||
}
|
||||
else if (val > 1)
|
||||
{
|
||||
if (d > 1) centinaia.cut(centinaia.len()-1);
|
||||
if (d > 1)
|
||||
centinaia.cut (centinaia.len () - 1);
|
||||
centinaia << "un" << (migliaia ? potenze[migliaia] : "o");
|
||||
} else centinaia = uni[migliaia];
|
||||
}
|
||||
else
|
||||
centinaia = uni[migliaia];
|
||||
|
||||
risultato.insert (centinaia, 0);
|
||||
}
|
||||
|
||||
if (negativo) risultato.insert("meno", 0);
|
||||
if (negativo)
|
||||
risultato.insert ("meno", 0);
|
||||
return __string;
|
||||
}
|
||||
|
||||
|
||||
// Certified 75%
|
||||
char* real::points(int dec) const
|
||||
char *real ::
|
||||
points (int dec)
|
||||
const
|
||||
{
|
||||
const char *str = stringa ();
|
||||
const int neg = (*str == '-') ? 1 : 0;
|
||||
@ -302,14 +348,19 @@ char* real::points(int dec) const
|
||||
int i;
|
||||
|
||||
int dot = n.find (',');
|
||||
if (dot < 0) dot = n.len();
|
||||
if (dot < 0)
|
||||
dot = n.len ();
|
||||
|
||||
if (dec > 0)
|
||||
{
|
||||
if (n[dot] == '\0') n << ',';
|
||||
const int d = strlen(str+dot+1); // Decimals already there
|
||||
if (n[dot] == '\0')
|
||||
n << ',';
|
||||
const int d = strlen (str + dot + 1); // Decimals already
|
||||
// there
|
||||
|
||||
if (d <= dec)
|
||||
for (i = d; i < dec; i++) n << '0';
|
||||
for (i = d; i < dec; i++)
|
||||
n << '0';
|
||||
else
|
||||
n.cut (dot + dec + 1);
|
||||
}
|
||||
@ -320,8 +371,8 @@ char* real::points(int dec) const
|
||||
return __string;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int get_picture_decimals(const TString& picture)
|
||||
HIDDEN int
|
||||
get_picture_decimals (const TString & picture)
|
||||
{
|
||||
int decimali = 0;
|
||||
const int virgola = picture.find (',');
|
||||
@ -329,17 +380,22 @@ HIDDEN int get_picture_decimals(const TString& picture)
|
||||
{
|
||||
const int len = picture.len ();
|
||||
for (int i = virgola + 1; i < len; i++)
|
||||
if (strchr("#@~", picture[i])) decimali++;
|
||||
if (strchr ("#@~", picture[i]))
|
||||
decimali++;
|
||||
}
|
||||
return decimali;
|
||||
}
|
||||
|
||||
|
||||
char* real::string(const char* picture) const
|
||||
char *real ::
|
||||
string (const char *picture)
|
||||
const
|
||||
{
|
||||
if (*picture == '\0') return string();
|
||||
if (*picture == '.') return points(atoi(picture+1));
|
||||
if (strcmp(picture, "LETTERE") == 0) return literals();
|
||||
if (*picture == '\0')
|
||||
return string ();
|
||||
if (*picture == '.')
|
||||
return points (atoi (picture + 1));
|
||||
if (strcmp (picture, "LETTERE") == 0)
|
||||
return literals ();
|
||||
|
||||
TString v (string ());
|
||||
TString f (picture);
|
||||
@ -348,7 +404,8 @@ char* real::string(const char* picture) const
|
||||
const int virgola = v.find ('.');
|
||||
int decimali = (virgola >= 0) ? v.len () - virgola - 1 : 0;
|
||||
|
||||
for ( ;voluti > decimali; decimali++) v << '@';
|
||||
for (; voluti > decimali; decimali++)
|
||||
v << '@';
|
||||
if (voluti < decimali)
|
||||
v.cut (virgola + voluti + (voluti > 0));
|
||||
|
||||
@ -359,9 +416,12 @@ char* real::string(const char* picture) const
|
||||
if (strchr ("#@~", z))
|
||||
{
|
||||
char c = v[j--];
|
||||
if (v[j] == '.') j--;
|
||||
if (z == '~') c = ' '; else
|
||||
if (c == '@') c = (z == '@') ? '0' : ' ';
|
||||
if (v[j] == '.')
|
||||
j--;
|
||||
if (z == '~')
|
||||
c = ' ';
|
||||
else if (c == '@')
|
||||
c = (z == '@') ? '0' : ' ';
|
||||
z = c;
|
||||
}
|
||||
}
|
||||
@ -370,21 +430,24 @@ char* real::string(const char* picture) const
|
||||
{
|
||||
case '#':
|
||||
case '~':
|
||||
case '.': f[i] = ' '; break;
|
||||
case '@': f[i] = '0'; break;
|
||||
default :break;
|
||||
case '.':
|
||||
f[i] = ' ';
|
||||
break;
|
||||
case '@':
|
||||
f[i] = '0';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return strcpy (__string, f);
|
||||
}
|
||||
|
||||
|
||||
ostream & operator << (ostream & out, const real & a)
|
||||
|
||||
{
|
||||
return out << a.string ();
|
||||
}
|
||||
|
||||
|
||||
istream & operator >> (istream & in, real & a)
|
||||
|
||||
{
|
||||
@ -393,13 +456,12 @@ istream& operator >>(istream& in, real& a)
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
int real::precision()
|
||||
int real ::
|
||||
precision ()
|
||||
{
|
||||
return dprec (ptr ());
|
||||
}
|
||||
|
||||
|
||||
real & real ::round (int prec)
|
||||
{
|
||||
if (prec < 0)
|
||||
@ -414,7 +476,6 @@ real& real::round(int prec)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
real & real ::ceil (int prec)
|
||||
{
|
||||
double p = 1.0;
|
||||
@ -424,8 +485,11 @@ real& real::ceil(int prec)
|
||||
divdfd (ptr (), ptr (), p);
|
||||
}
|
||||
|
||||
DEC integer; dint(&integer, ptr()); // Extract the integer part
|
||||
DEC integer;
|
||||
dint (&integer, ptr ()); // Extract the integer part
|
||||
|
||||
if (disne (ptr (), &integer)) // If different ...
|
||||
|
||||
addid (ptr (), &integer, 1); // add 1
|
||||
|
||||
if (prec)
|
||||
@ -434,14 +498,12 @@ real& real::ceil(int prec)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
real & real ::trunc (int prec)
|
||||
{
|
||||
dtrunc (ptr (), ptr (), prec);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
real operator + (const real & a, const real & b)
|
||||
|
||||
{
|
||||
@ -449,7 +511,6 @@ real operator +(const real& a, const real& b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real operator + (double a, const real & b)
|
||||
|
||||
{
|
||||
@ -457,7 +518,6 @@ real operator +(double a, const real& b)
|
||||
return __tmp_real += b;
|
||||
}
|
||||
|
||||
|
||||
real operator + (const real & a, double b)
|
||||
|
||||
{
|
||||
@ -465,7 +525,6 @@ real operator +(const real& a, double b)
|
||||
return __tmp_real += b;
|
||||
}
|
||||
|
||||
|
||||
real operator - (const real & a, const real & b)
|
||||
|
||||
{
|
||||
@ -473,7 +532,6 @@ real operator -(const real& a, const real& b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real operator - (double a, const real & b)
|
||||
|
||||
{
|
||||
@ -482,7 +540,6 @@ real operator -(double a, const real& b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real operator - (const real & a, double b)
|
||||
|
||||
{
|
||||
@ -490,7 +547,6 @@ real operator -(const real& a, double b)
|
||||
return __tmp_real -= a;
|
||||
}
|
||||
|
||||
|
||||
real operator *(const real & a, const real & b)
|
||||
|
||||
{
|
||||
@ -498,7 +554,6 @@ real operator *(const real& a, const real& b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real operator *(double a, const real & b)
|
||||
|
||||
{
|
||||
@ -506,7 +561,6 @@ real operator *(double a, const real& b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real operator *(const real & a, double b)
|
||||
|
||||
{
|
||||
@ -514,7 +568,6 @@ real operator *(const real& a, double b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real operator / (const real & a, const real & b)
|
||||
|
||||
{
|
||||
@ -522,7 +575,6 @@ real operator /(const real& a, const real& b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real operator / (double a, const real & b)
|
||||
|
||||
{
|
||||
@ -531,7 +583,6 @@ real operator /(double a, const real& b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real operator / (const real & a, double b)
|
||||
|
||||
{
|
||||
@ -540,13 +591,11 @@ real operator /(const real& a, double b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
bool operator > (const real & a, const real & b)
|
||||
{
|
||||
return disgt (a.ptr (), b.ptr ());
|
||||
}
|
||||
|
||||
|
||||
bool operator > (double a, const real & b)
|
||||
{
|
||||
// dftod(__tmp_real.ptr(), a);
|
||||
@ -555,14 +604,12 @@ bool operator >(double a, const real& b)
|
||||
return a > n;
|
||||
}
|
||||
|
||||
|
||||
bool operator < (const real & a, const real & b)
|
||||
|
||||
{
|
||||
return dislt (a.ptr (), b.ptr ());
|
||||
}
|
||||
|
||||
|
||||
bool operator < (double a, const real & b)
|
||||
|
||||
{
|
||||
@ -572,14 +619,12 @@ bool operator <(double a, const real& b)
|
||||
return a < n;
|
||||
}
|
||||
|
||||
|
||||
bool operator >= (const real & a, const real & b)
|
||||
|
||||
{
|
||||
return disge (a.ptr (), b.ptr ());
|
||||
}
|
||||
|
||||
|
||||
bool operator >= (double a, const real & b)
|
||||
|
||||
{
|
||||
@ -589,14 +634,12 @@ bool operator >=(double a, const real& b)
|
||||
return a >= n;
|
||||
}
|
||||
|
||||
|
||||
bool operator <= (const real & a, const real & b)
|
||||
|
||||
{
|
||||
return disle (a.ptr (), b.ptr ());
|
||||
}
|
||||
|
||||
|
||||
bool operator <= (double a, const real & b)
|
||||
|
||||
{
|
||||
@ -606,27 +649,23 @@ bool operator <=(double a, const real& b)
|
||||
return a <= n;
|
||||
}
|
||||
|
||||
|
||||
bool operator == (const real & a, const real & b)
|
||||
{
|
||||
return diseq (a.ptr (), b.ptr ());
|
||||
}
|
||||
|
||||
|
||||
bool operator == (double a, const real & b)
|
||||
{
|
||||
const double n = dtodf (b.ptr ());
|
||||
return a == n;
|
||||
}
|
||||
|
||||
|
||||
bool operator != (const real & a, const real & b)
|
||||
|
||||
{
|
||||
return !diseq (a.ptr (), b.ptr ());
|
||||
}
|
||||
|
||||
|
||||
bool operator != (double a, const real & b)
|
||||
|
||||
{
|
||||
@ -634,7 +673,6 @@ bool operator !=(double a, const real& b)
|
||||
return a != n;
|
||||
}
|
||||
|
||||
|
||||
real operator % (const real & a, const long b)
|
||||
|
||||
{
|
||||
@ -642,14 +680,12 @@ real operator %(const real& a, const long b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
void swap (real & a, real & b)
|
||||
|
||||
{
|
||||
SwapDecimal (a.ptr (), b.ptr ());
|
||||
}
|
||||
|
||||
|
||||
real fnc_min (const real & a, const real & b)
|
||||
|
||||
{
|
||||
@ -657,7 +693,6 @@ real fnc_min(const real& a, const real& b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real fnc_max (const real & a, const real & b)
|
||||
|
||||
{
|
||||
@ -665,7 +700,6 @@ real fnc_max(const real& a, const real& b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real sqrt (const real & a)
|
||||
|
||||
{
|
||||
@ -673,7 +707,6 @@ real sqrt(const real& a)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real sqr (const real & a)
|
||||
|
||||
{
|
||||
@ -681,7 +714,6 @@ real sqr(const real& a)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real exp10 (const real & a)
|
||||
|
||||
{
|
||||
@ -689,7 +721,6 @@ real exp10(const real& a)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real pow (const real & a, const real & b)
|
||||
|
||||
{
|
||||
@ -697,7 +728,6 @@ real pow(const real& a, const real& b)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real exp (const real & a)
|
||||
|
||||
{
|
||||
@ -712,7 +742,6 @@ real log10(const real& a)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real log (const real & a)
|
||||
|
||||
{
|
||||
@ -720,7 +749,6 @@ real log(const real& a)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real sin (const real & a)
|
||||
|
||||
{
|
||||
@ -728,7 +756,6 @@ real sin(const real& a)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real cos (const real & a)
|
||||
|
||||
{
|
||||
@ -736,7 +763,6 @@ real cos(const real& a)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real tan (const real & a)
|
||||
|
||||
{
|
||||
@ -744,7 +770,6 @@ real tan(const real& a)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
real abs (const real & a)
|
||||
|
||||
{
|
||||
@ -752,14 +777,12 @@ real abs(const real& a)
|
||||
return __tmp_real;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Distrib
|
||||
// Oggetto per dividere un real in varie sue percentuali
|
||||
// in modo che la loro somma dia sempre il real di partenza
|
||||
// /////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
void TDistrib ::add (real slice)
|
||||
{
|
||||
if (slice > real (1.0))
|
||||
@ -774,8 +797,12 @@ real TDistrib::get()
|
||||
CHECK (_current < _slices.items (), "TDistrib: too many gets");
|
||||
real r = _tot * ((real &) _slices[_current++]);
|
||||
r.round (_decs);
|
||||
if (r > _tot - _prog) { r = _tot-_prog; _prog = _tot; }
|
||||
else _prog += r;
|
||||
if (r > _tot - _prog)
|
||||
{
|
||||
r = _tot - _prog; _prog = _tot;
|
||||
}
|
||||
else
|
||||
_prog += r;
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -784,5 +811,3 @@ void TDistrib::init(const real& r)
|
||||
_current = 0; _prog = 0;
|
||||
_tot = r; _ready = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user