Corretta ceil per i numeri negativi (2 la vendetta).

git-svn-id: svn://10.65.10.50/trunk@27 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-08-17 14:07:28 +00:00
parent b6fc4a65e3
commit 3d2d9d579f

View File

@ -73,6 +73,7 @@ bool real::is_real (const char *s)
{
while (*s == ' ')
s++; // Remove leading spaces before atod
ok = atod (__tmp_real.ptr (), (char *) s) != GM_NULL;
}
return ok;
@ -144,8 +145,6 @@ real& real::operator /= (const real& b)
return *this;
}
TObject *real :: dup () const
{
return new real (*this);
@ -252,7 +251,7 @@ char *real::literals () const
{"", "uno", "due", "tre", "quattro",
"cinque", "sei", "sette", "otto",
"nove", "dieci", "undici", "dodici",
"tredici", "quattordici", "quindici", "sedici"
"tredici", "quattordici", "quindici", "sedici",
"diciassette", "diciotto", "diciannove"};
const char *decine[] =
{"zero", "dieci", "venti", "trenta", "quaranta",
@ -357,6 +356,7 @@ char *real::points (int dec) const
return __string;
}
HIDDEN int get_picture_decimals (const TString & picture)
{
int decimali = 0;
@ -371,7 +371,9 @@ HIDDEN int get_picture_decimals (const TString & picture)
return decimali;
}
char *real::string (const char *picture) const
char *real ::string (const char *picture)
const
{
if (*picture == '\0')
return string ();
@ -425,12 +427,13 @@ char *real::string (const char *picture) const
return strcpy (__string, f);
}
ostream& operator<< (ostream& out, const real& a)
ostream & operator << (ostream & out, const real & a)
{
return out << a.string ();
}
istream & operator >> (istream & in, real & a)
{
in >> __string;
@ -438,11 +441,13 @@ istream& operator>> (istream& in, real& a)
return in;
}
int real ::precision ()
{
return dprec (ptr ());
}
real & real ::round (int prec)
{
if (prec < 0)
@ -460,7 +465,7 @@ real& real::round (int prec)
real & real ::ceil (int prec)
{
double p = 1.0;
if (prec)
if (prec != 0)
{
p = ::pow (10.0, -prec);
divdfd (ptr (), ptr (), p);
@ -469,11 +474,12 @@ real& real::ceil (int prec)
DEC integer;
dint (&integer, ptr ()); // Extract the integer part
if (disne (ptr (), &integer)) // If different ...
if (disgt (ptr (), &integer)) // If positive ...
addid (ptr (), &integer, 1); // add 1
else
dcpy(ptr(), &integer); // If negative
if (prec)
if (prec != 0)
muldfd (ptr (), ptr (), p);
return *this;
@ -716,8 +722,6 @@ real exp (const real& a)
return __tmp_real;
}
real log10 (const real & a)
{