mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 02:52:24 +00:00
Improved Out.Real* layout and build type independence.
This commit is contained in:
parent
1a3364269e
commit
f0a68cf6f9
8 changed files with 456 additions and 210 deletions
|
|
@ -21,7 +21,7 @@ export void Out_Ln (void);
|
|||
export void Out_LongReal (LONGREAL x, int16 n);
|
||||
export void Out_Open (void);
|
||||
export void Out_Real (REAL x, int16 n);
|
||||
static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp);
|
||||
static void Out_RealP (LONGREAL x, int16 n, BOOLEAN long_);
|
||||
export void Out_String (CHAR *str, LONGINT str__len);
|
||||
export LONGREAL Out_Ten (int16 e);
|
||||
static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i);
|
||||
|
|
@ -167,12 +167,12 @@ LONGREAL Out_Ten (int16 e)
|
|||
return _o_result;
|
||||
}
|
||||
|
||||
static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp)
|
||||
static void Out_RealP (LONGREAL x, int16 n, BOOLEAN long_)
|
||||
{
|
||||
int16 e;
|
||||
int64 f;
|
||||
CHAR s[30];
|
||||
int16 i;
|
||||
int16 i, el;
|
||||
LONGREAL x0;
|
||||
BOOLEAN nn, en;
|
||||
int64 m;
|
||||
|
|
@ -191,16 +191,35 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i);
|
||||
}
|
||||
} else {
|
||||
if (long_) {
|
||||
el = 3;
|
||||
dr = n - 6;
|
||||
if (dr > 17) {
|
||||
dr = 17;
|
||||
}
|
||||
d = dr;
|
||||
if (d < 16) {
|
||||
d = 16;
|
||||
}
|
||||
} else {
|
||||
el = 2;
|
||||
dr = n - 5;
|
||||
if (dr > 9) {
|
||||
dr = 9;
|
||||
}
|
||||
d = dr;
|
||||
if (d < 7) {
|
||||
d = 7;
|
||||
}
|
||||
}
|
||||
if (e == 0) {
|
||||
d = i - exponentdigits;
|
||||
while (i > d) {
|
||||
while (el > 0) {
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = '0';
|
||||
el -= 1;
|
||||
}
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = '+';
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = exp;
|
||||
m = 0;
|
||||
} else {
|
||||
if (nn) {
|
||||
|
|
@ -220,11 +239,10 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
if (en) {
|
||||
e = -e;
|
||||
}
|
||||
d = exponentdigits;
|
||||
while (d > 0) {
|
||||
while (el > 0) {
|
||||
Out_digit(e, (void*)s, 30, &i);
|
||||
e = __DIV(e, 10);
|
||||
d -= 1;
|
||||
el -= 1;
|
||||
}
|
||||
i -= 1;
|
||||
if (en) {
|
||||
|
|
@ -232,9 +250,7 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
} else {
|
||||
s[__X(i, 30)] = '+';
|
||||
}
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = exp;
|
||||
x0 = Out_Ten(maxsigdigits - 1);
|
||||
x0 = Out_Ten(d - 1);
|
||||
x = x0 * x + 5.00000000000000e-001;
|
||||
if (x >= (LONGREAL)10 * x0) {
|
||||
x = 1.00000000000000e-001 * x;
|
||||
|
|
@ -242,8 +258,12 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
}
|
||||
m = Out_Entier64(x);
|
||||
}
|
||||
d = maxsigdigits;
|
||||
dr = n - (exponentdigits + 3);
|
||||
i -= 1;
|
||||
if (long_) {
|
||||
s[__X(i, 30)] = 'D';
|
||||
} else {
|
||||
s[__X(i, 30)] = 'E';
|
||||
}
|
||||
if (dr < 2) {
|
||||
dr = 2;
|
||||
}
|
||||
|
|
@ -276,12 +296,12 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
|
||||
void Out_Real (REAL x, int16 n)
|
||||
{
|
||||
Out_RealP(x, n, 2, 7, 'E');
|
||||
Out_RealP(x, n, 0);
|
||||
}
|
||||
|
||||
void Out_LongReal (LONGREAL x, int16 n)
|
||||
{
|
||||
Out_RealP(x, n, 3, 16, 'D');
|
||||
Out_RealP(x, n, 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export void Out_Ln (void);
|
|||
export void Out_LongReal (LONGREAL x, int16 n);
|
||||
export void Out_Open (void);
|
||||
export void Out_Real (REAL x, int16 n);
|
||||
static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp);
|
||||
static void Out_RealP (LONGREAL x, int16 n, BOOLEAN long_);
|
||||
export void Out_String (CHAR *str, LONGINT str__len);
|
||||
export LONGREAL Out_Ten (int16 e);
|
||||
static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i);
|
||||
|
|
@ -167,12 +167,12 @@ LONGREAL Out_Ten (int16 e)
|
|||
return _o_result;
|
||||
}
|
||||
|
||||
static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp)
|
||||
static void Out_RealP (LONGREAL x, int16 n, BOOLEAN long_)
|
||||
{
|
||||
int16 e;
|
||||
int64 f;
|
||||
CHAR s[30];
|
||||
int16 i;
|
||||
int16 i, el;
|
||||
LONGREAL x0;
|
||||
BOOLEAN nn, en;
|
||||
int64 m;
|
||||
|
|
@ -191,16 +191,35 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i);
|
||||
}
|
||||
} else {
|
||||
if (long_) {
|
||||
el = 3;
|
||||
dr = n - 6;
|
||||
if (dr > 17) {
|
||||
dr = 17;
|
||||
}
|
||||
d = dr;
|
||||
if (d < 16) {
|
||||
d = 16;
|
||||
}
|
||||
} else {
|
||||
el = 2;
|
||||
dr = n - 5;
|
||||
if (dr > 9) {
|
||||
dr = 9;
|
||||
}
|
||||
d = dr;
|
||||
if (d < 7) {
|
||||
d = 7;
|
||||
}
|
||||
}
|
||||
if (e == 0) {
|
||||
d = i - exponentdigits;
|
||||
while (i > d) {
|
||||
while (el > 0) {
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = '0';
|
||||
el -= 1;
|
||||
}
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = '+';
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = exp;
|
||||
m = 0;
|
||||
} else {
|
||||
if (nn) {
|
||||
|
|
@ -220,11 +239,10 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
if (en) {
|
||||
e = -e;
|
||||
}
|
||||
d = exponentdigits;
|
||||
while (d > 0) {
|
||||
while (el > 0) {
|
||||
Out_digit(e, (void*)s, 30, &i);
|
||||
e = __DIV(e, 10);
|
||||
d -= 1;
|
||||
el -= 1;
|
||||
}
|
||||
i -= 1;
|
||||
if (en) {
|
||||
|
|
@ -232,9 +250,7 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
} else {
|
||||
s[__X(i, 30)] = '+';
|
||||
}
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = exp;
|
||||
x0 = Out_Ten(maxsigdigits - 1);
|
||||
x0 = Out_Ten(d - 1);
|
||||
x = x0 * x + 5.00000000000000e-001;
|
||||
if (x >= (LONGREAL)10 * x0) {
|
||||
x = 1.00000000000000e-001 * x;
|
||||
|
|
@ -242,8 +258,12 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
}
|
||||
m = Out_Entier64(x);
|
||||
}
|
||||
d = maxsigdigits;
|
||||
dr = n - (exponentdigits + 3);
|
||||
i -= 1;
|
||||
if (long_) {
|
||||
s[__X(i, 30)] = 'D';
|
||||
} else {
|
||||
s[__X(i, 30)] = 'E';
|
||||
}
|
||||
if (dr < 2) {
|
||||
dr = 2;
|
||||
}
|
||||
|
|
@ -276,12 +296,12 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
|
||||
void Out_Real (REAL x, int16 n)
|
||||
{
|
||||
Out_RealP(x, n, 2, 7, 'E');
|
||||
Out_RealP(x, n, 0);
|
||||
}
|
||||
|
||||
void Out_LongReal (LONGREAL x, int16 n)
|
||||
{
|
||||
Out_RealP(x, n, 3, 16, 'D');
|
||||
Out_RealP(x, n, 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export void Out_Ln (void);
|
|||
export void Out_LongReal (LONGREAL x, int16 n);
|
||||
export void Out_Open (void);
|
||||
export void Out_Real (REAL x, int16 n);
|
||||
static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp);
|
||||
static void Out_RealP (LONGREAL x, int16 n, BOOLEAN long_);
|
||||
export void Out_String (CHAR *str, LONGINT str__len);
|
||||
export LONGREAL Out_Ten (int16 e);
|
||||
static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i);
|
||||
|
|
@ -167,12 +167,12 @@ LONGREAL Out_Ten (int16 e)
|
|||
return _o_result;
|
||||
}
|
||||
|
||||
static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp)
|
||||
static void Out_RealP (LONGREAL x, int16 n, BOOLEAN long_)
|
||||
{
|
||||
int16 e;
|
||||
int64 f;
|
||||
CHAR s[30];
|
||||
int16 i;
|
||||
int16 i, el;
|
||||
LONGREAL x0;
|
||||
BOOLEAN nn, en;
|
||||
int64 m;
|
||||
|
|
@ -191,16 +191,35 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i);
|
||||
}
|
||||
} else {
|
||||
if (long_) {
|
||||
el = 3;
|
||||
dr = n - 6;
|
||||
if (dr > 17) {
|
||||
dr = 17;
|
||||
}
|
||||
d = dr;
|
||||
if (d < 16) {
|
||||
d = 16;
|
||||
}
|
||||
} else {
|
||||
el = 2;
|
||||
dr = n - 5;
|
||||
if (dr > 9) {
|
||||
dr = 9;
|
||||
}
|
||||
d = dr;
|
||||
if (d < 7) {
|
||||
d = 7;
|
||||
}
|
||||
}
|
||||
if (e == 0) {
|
||||
d = i - exponentdigits;
|
||||
while (i > d) {
|
||||
while (el > 0) {
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = '0';
|
||||
el -= 1;
|
||||
}
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = '+';
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = exp;
|
||||
m = 0;
|
||||
} else {
|
||||
if (nn) {
|
||||
|
|
@ -220,11 +239,10 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
if (en) {
|
||||
e = -e;
|
||||
}
|
||||
d = exponentdigits;
|
||||
while (d > 0) {
|
||||
while (el > 0) {
|
||||
Out_digit(e, (void*)s, 30, &i);
|
||||
e = __DIV(e, 10);
|
||||
d -= 1;
|
||||
el -= 1;
|
||||
}
|
||||
i -= 1;
|
||||
if (en) {
|
||||
|
|
@ -232,9 +250,7 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
} else {
|
||||
s[__X(i, 30)] = '+';
|
||||
}
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = exp;
|
||||
x0 = Out_Ten(maxsigdigits - 1);
|
||||
x0 = Out_Ten(d - 1);
|
||||
x = x0 * x + 5.00000000000000e-001;
|
||||
if (x >= (LONGREAL)10 * x0) {
|
||||
x = 1.00000000000000e-001 * x;
|
||||
|
|
@ -242,8 +258,12 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
}
|
||||
m = Out_Entier64(x);
|
||||
}
|
||||
d = maxsigdigits;
|
||||
dr = n - (exponentdigits + 3);
|
||||
i -= 1;
|
||||
if (long_) {
|
||||
s[__X(i, 30)] = 'D';
|
||||
} else {
|
||||
s[__X(i, 30)] = 'E';
|
||||
}
|
||||
if (dr < 2) {
|
||||
dr = 2;
|
||||
}
|
||||
|
|
@ -276,12 +296,12 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
|
||||
void Out_Real (REAL x, int16 n)
|
||||
{
|
||||
Out_RealP(x, n, 2, 7, 'E');
|
||||
Out_RealP(x, n, 0);
|
||||
}
|
||||
|
||||
void Out_LongReal (LONGREAL x, int16 n)
|
||||
{
|
||||
Out_RealP(x, n, 3, 16, 'D');
|
||||
Out_RealP(x, n, 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export void Out_Ln (void);
|
|||
export void Out_LongReal (LONGREAL x, int16 n);
|
||||
export void Out_Open (void);
|
||||
export void Out_Real (REAL x, int16 n);
|
||||
static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp);
|
||||
static void Out_RealP (LONGREAL x, int16 n, BOOLEAN long_);
|
||||
export void Out_String (CHAR *str, LONGINT str__len);
|
||||
export LONGREAL Out_Ten (int16 e);
|
||||
static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i);
|
||||
|
|
@ -167,12 +167,12 @@ LONGREAL Out_Ten (int16 e)
|
|||
return _o_result;
|
||||
}
|
||||
|
||||
static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp)
|
||||
static void Out_RealP (LONGREAL x, int16 n, BOOLEAN long_)
|
||||
{
|
||||
int16 e;
|
||||
int64 f;
|
||||
CHAR s[30];
|
||||
int16 i;
|
||||
int16 i, el;
|
||||
LONGREAL x0;
|
||||
BOOLEAN nn, en;
|
||||
int64 m;
|
||||
|
|
@ -191,16 +191,35 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i);
|
||||
}
|
||||
} else {
|
||||
if (long_) {
|
||||
el = 3;
|
||||
dr = n - 6;
|
||||
if (dr > 17) {
|
||||
dr = 17;
|
||||
}
|
||||
d = dr;
|
||||
if (d < 16) {
|
||||
d = 16;
|
||||
}
|
||||
} else {
|
||||
el = 2;
|
||||
dr = n - 5;
|
||||
if (dr > 9) {
|
||||
dr = 9;
|
||||
}
|
||||
d = dr;
|
||||
if (d < 7) {
|
||||
d = 7;
|
||||
}
|
||||
}
|
||||
if (e == 0) {
|
||||
d = i - exponentdigits;
|
||||
while (i > d) {
|
||||
while (el > 0) {
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = '0';
|
||||
el -= 1;
|
||||
}
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = '+';
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = exp;
|
||||
m = 0;
|
||||
} else {
|
||||
if (nn) {
|
||||
|
|
@ -220,11 +239,10 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
if (en) {
|
||||
e = -e;
|
||||
}
|
||||
d = exponentdigits;
|
||||
while (d > 0) {
|
||||
while (el > 0) {
|
||||
Out_digit(e, (void*)s, 30, &i);
|
||||
e = __DIV(e, 10);
|
||||
d -= 1;
|
||||
el -= 1;
|
||||
}
|
||||
i -= 1;
|
||||
if (en) {
|
||||
|
|
@ -232,9 +250,7 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
} else {
|
||||
s[__X(i, 30)] = '+';
|
||||
}
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = exp;
|
||||
x0 = Out_Ten(maxsigdigits - 1);
|
||||
x0 = Out_Ten(d - 1);
|
||||
x = x0 * x + 5.00000000000000e-001;
|
||||
if (x >= (LONGREAL)10 * x0) {
|
||||
x = 1.00000000000000e-001 * x;
|
||||
|
|
@ -242,8 +258,12 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
}
|
||||
m = Out_Entier64(x);
|
||||
}
|
||||
d = maxsigdigits;
|
||||
dr = n - (exponentdigits + 3);
|
||||
i -= 1;
|
||||
if (long_) {
|
||||
s[__X(i, 30)] = 'D';
|
||||
} else {
|
||||
s[__X(i, 30)] = 'E';
|
||||
}
|
||||
if (dr < 2) {
|
||||
dr = 2;
|
||||
}
|
||||
|
|
@ -276,12 +296,12 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
|
||||
void Out_Real (REAL x, int16 n)
|
||||
{
|
||||
Out_RealP(x, n, 2, 7, 'E');
|
||||
Out_RealP(x, n, 0);
|
||||
}
|
||||
|
||||
void Out_LongReal (LONGREAL x, int16 n)
|
||||
{
|
||||
Out_RealP(x, n, 3, 16, 'D');
|
||||
Out_RealP(x, n, 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export void Out_Ln (void);
|
|||
export void Out_LongReal (LONGREAL x, int16 n);
|
||||
export void Out_Open (void);
|
||||
export void Out_Real (REAL x, int16 n);
|
||||
static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp);
|
||||
static void Out_RealP (LONGREAL x, int16 n, BOOLEAN long_);
|
||||
export void Out_String (CHAR *str, LONGINT str__len);
|
||||
export LONGREAL Out_Ten (int16 e);
|
||||
static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i);
|
||||
|
|
@ -167,12 +167,12 @@ LONGREAL Out_Ten (int16 e)
|
|||
return _o_result;
|
||||
}
|
||||
|
||||
static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp)
|
||||
static void Out_RealP (LONGREAL x, int16 n, BOOLEAN long_)
|
||||
{
|
||||
int16 e;
|
||||
int64 f;
|
||||
CHAR s[30];
|
||||
int16 i;
|
||||
int16 i, el;
|
||||
LONGREAL x0;
|
||||
BOOLEAN nn, en;
|
||||
int64 m;
|
||||
|
|
@ -191,16 +191,35 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i);
|
||||
}
|
||||
} else {
|
||||
if (long_) {
|
||||
el = 3;
|
||||
dr = n - 6;
|
||||
if (dr > 17) {
|
||||
dr = 17;
|
||||
}
|
||||
d = dr;
|
||||
if (d < 16) {
|
||||
d = 16;
|
||||
}
|
||||
} else {
|
||||
el = 2;
|
||||
dr = n - 5;
|
||||
if (dr > 9) {
|
||||
dr = 9;
|
||||
}
|
||||
d = dr;
|
||||
if (d < 7) {
|
||||
d = 7;
|
||||
}
|
||||
}
|
||||
if (e == 0) {
|
||||
d = i - exponentdigits;
|
||||
while (i > d) {
|
||||
while (el > 0) {
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = '0';
|
||||
el -= 1;
|
||||
}
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = '+';
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = exp;
|
||||
m = 0;
|
||||
} else {
|
||||
if (nn) {
|
||||
|
|
@ -220,11 +239,10 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
if (en) {
|
||||
e = -e;
|
||||
}
|
||||
d = exponentdigits;
|
||||
while (d > 0) {
|
||||
while (el > 0) {
|
||||
Out_digit(e, (void*)s, 30, &i);
|
||||
e = __DIV(e, 10);
|
||||
d -= 1;
|
||||
el -= 1;
|
||||
}
|
||||
i -= 1;
|
||||
if (en) {
|
||||
|
|
@ -232,9 +250,7 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
} else {
|
||||
s[__X(i, 30)] = '+';
|
||||
}
|
||||
i -= 1;
|
||||
s[__X(i, 30)] = exp;
|
||||
x0 = Out_Ten(maxsigdigits - 1);
|
||||
x0 = Out_Ten(d - 1);
|
||||
x = x0 * x + 5.00000000000000e-001;
|
||||
if (x >= (LONGREAL)10 * x0) {
|
||||
x = 1.00000000000000e-001 * x;
|
||||
|
|
@ -242,8 +258,12 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
}
|
||||
m = Out_Entier64(x);
|
||||
}
|
||||
d = maxsigdigits;
|
||||
dr = n - (exponentdigits + 3);
|
||||
i -= 1;
|
||||
if (long_) {
|
||||
s[__X(i, 30)] = 'D';
|
||||
} else {
|
||||
s[__X(i, 30)] = 'E';
|
||||
}
|
||||
if (dr < 2) {
|
||||
dr = 2;
|
||||
}
|
||||
|
|
@ -276,12 +296,12 @@ static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdi
|
|||
|
||||
void Out_Real (REAL x, int16 n)
|
||||
{
|
||||
Out_RealP(x, n, 2, 7, 'E');
|
||||
Out_RealP(x, n, 0);
|
||||
}
|
||||
|
||||
void Out_LongReal (LONGREAL x, int16 n)
|
||||
{
|
||||
Out_RealP(x, n, 3, 16, 'D');
|
||||
Out_RealP(x, n, 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ END Ten;
|
|||
|
||||
PROCEDURE -Entier64(x: LONGREAL): SYSTEM.INT64 "(int64)(x)";
|
||||
|
||||
PROCEDURE RealP(x: LONGREAL; n, exponentdigits, maxsigdigits: INTEGER; exp: CHAR);
|
||||
PROCEDURE RealP(x: LONGREAL; n: INTEGER; long: BOOLEAN);
|
||||
|
||||
(* LongReal(x, n) writes the long real number x to the end of the output stream using an
|
||||
exponential form. If the textual representation of x requires m characters (including a
|
||||
|
|
@ -104,16 +104,17 @@ PROCEDURE RealP(x: LONGREAL; n, exponentdigits, maxsigdigits: INTEGER; exp: CHAR
|
|||
LONGREAL is 1/sign, 11/exponent, 52/significand *)
|
||||
|
||||
VAR
|
||||
e: INTEGER; (* Exponent field *)
|
||||
f: HUGEINT; (* Fraction field *)
|
||||
s: ARRAY 30 OF CHAR; (* Buffer built backwards *)
|
||||
i: INTEGER; (* Index into s *)
|
||||
x0: LONGREAL;
|
||||
nn: BOOLEAN; (* Number negative *)
|
||||
en: BOOLEAN; (* Exponent negative *)
|
||||
m: HUGEINT; (* Mantissa digits *)
|
||||
d: INTEGER; (* Significant digit count to display *)
|
||||
dr: INTEGER; (* Number of insignificant digits that can be dropped *)
|
||||
e: INTEGER; (* Exponent field *)
|
||||
f: HUGEINT; (* Fraction field *)
|
||||
s: ARRAY 30 OF CHAR; (* Buffer built backwards *)
|
||||
i: INTEGER; (* Index into s *)
|
||||
el: INTEGER; (* Exponent length *)
|
||||
x0: LONGREAL;
|
||||
nn: BOOLEAN; (* Number negative *)
|
||||
en: BOOLEAN; (* Exponent negative *)
|
||||
m: HUGEINT; (* Mantissa digits *)
|
||||
d: INTEGER; (* Significant digit count to display *)
|
||||
dr: INTEGER; (* Number of insignificant digits that can be dropped *)
|
||||
|
||||
BEGIN
|
||||
nn := SYSTEM.VAL(HUGEINT, x) < 0; IF nn THEN DEC(n) END;
|
||||
|
|
@ -124,10 +125,25 @@ BEGIN
|
|||
IF e = 7FFH THEN (* NaN / Infinity *)
|
||||
IF f = 0 THEN prepend("Infinity", s, i) ELSE prepend("NaN", s, i) END
|
||||
ELSE
|
||||
(* Calculate number of significant digits caller has proposed space for, and
|
||||
number of digits to generate. *)
|
||||
IF long THEN
|
||||
el := 3;
|
||||
dr := n-6; (* Leave room for dp and '+D000' *)
|
||||
IF dr > 17 THEN dr := 17 END; (* Limit to max useful significant digits *)
|
||||
d := dr; (* Number of digits to generate *)
|
||||
IF d < 16 THEN d := 16 END (* Generate enough digits to do trailing zero supporession *)
|
||||
ELSE
|
||||
el := 2;
|
||||
dr := n-5; (* Leave room for dp and '+E00' *)
|
||||
IF dr > 9 THEN dr := 9 END; (* Limit to max useful significant digits *)
|
||||
d := dr; (* Number of digits to generate *)
|
||||
IF d < 7 THEN d := 7 END (* Generate enough digits to do trailing zero supporession *)
|
||||
END;
|
||||
|
||||
IF e = 0 THEN
|
||||
d := i - exponentdigits; WHILE i > d DO DEC(i); s[i] := "0" END;
|
||||
WHILE el > 0 DO DEC(i); s[i] := "0"; DEC(el) END;
|
||||
DEC(i); s[i] := "+";
|
||||
DEC(i); s[i] := exp;
|
||||
m := 0;
|
||||
ELSE
|
||||
IF nn THEN x := -x END;
|
||||
|
|
@ -139,25 +155,23 @@ BEGIN
|
|||
|
||||
(* Generate the exponent digits *)
|
||||
en := e < 0; IF en THEN e := - e END;
|
||||
d := exponentdigits;
|
||||
WHILE d > 0 DO digit(e, s, i); e := e DIV 10; DEC(d) END;
|
||||
WHILE el > 0 DO digit(e, s, i); e := e DIV 10; DEC(el) END;
|
||||
DEC(i); IF en THEN s[i] := "-" ELSE s[i] := "+" END;
|
||||
DEC(i); s[i] := exp;
|
||||
|
||||
(* Todo: generate more than maxsigdigits if we have room for them *)
|
||||
|
||||
(* Scale x to enoughsignificant digits to reliably test for trailing
|
||||
zeroes.
|
||||
todo or to the amount of space available, if greater. *)
|
||||
x0 := Ten(maxsigdigits-1);
|
||||
x := x0 * x + 0.5D0;
|
||||
(* Scale x to enough significant digits to reliably test for trailing
|
||||
zeroes or to the amount of space available, if greater. *)
|
||||
x0 := Ten(d-1);
|
||||
x := x0 * x;
|
||||
x := x + 0.5D0; (* Do not combine with previous line as doing so
|
||||
introduces a least significant bit difference
|
||||
between 32 bit and 64 bit builds. *)
|
||||
IF x >= 10.0D0 * x0 THEN x := 0.1D0 * x; INC(e) END;
|
||||
m := Entier64(x)
|
||||
END;
|
||||
|
||||
(* Drop trailing zeroes where we don't have room *)
|
||||
d := maxsigdigits;
|
||||
dr := n - (exponentdigits + 3); (* 3 for '.', D/E and +/- *)
|
||||
DEC(i); IF long THEN s[i] := "D" ELSE s[i] := "E" END;
|
||||
|
||||
(* Drop trailing zeroes where caller proposes to use less space *)
|
||||
IF dr < 2 THEN dr := 2 END;
|
||||
WHILE (d > dr) & (m MOD 10 = 0) DO m := m DIV 10; DEC(d) END;
|
||||
|
||||
|
|
@ -177,11 +191,11 @@ END RealP;
|
|||
|
||||
|
||||
PROCEDURE Real*(x: REAL; n: INTEGER);
|
||||
BEGIN RealP(x, n, 2, 7, "E");
|
||||
BEGIN RealP(x, n, FALSE);
|
||||
END Real;
|
||||
|
||||
PROCEDURE LongReal*(x: LONGREAL; n: INTEGER);
|
||||
BEGIN RealP(x, n, 3, 16, "D");
|
||||
BEGIN RealP(x, n, TRUE);
|
||||
END LongReal;
|
||||
|
||||
END Out.
|
||||
|
|
|
|||
|
|
@ -1,11 +1,39 @@
|
|||
--- Testing with Oberon 2 variable model ---
|
||||
Real number hex representation.
|
||||
1.0D0: 3FF0000000000000
|
||||
1.1D0: 3FF199999999999A
|
||||
2.1D0: 4000CCCCCCCCCCCD
|
||||
-1.1D0: BFF199999999999A
|
||||
1.1D3: 4091300000000000
|
||||
1.1D-3: 3F5205BC01A36E2F
|
||||
1.2345678987654321D3: 40934A45874103D8
|
||||
0.0: 0000000000000000
|
||||
0.000123D0: 3F201F31F46ED246
|
||||
1/0.0: 7FF0000000000000
|
||||
-1/0.0: FFF0000000000000
|
||||
0.0/0.0: FFF8000000000000
|
||||
|
||||
1.0E0: 3F800000
|
||||
1.1E0: 3F8CCCCD
|
||||
2.1E0: 40066666
|
||||
-1.1E0: BF8CCCCD
|
||||
1.1E3: 44898000
|
||||
1.1E-3: 3A902DE0
|
||||
1.2345678987654321E3: 449A522C
|
||||
0.0: 00000000
|
||||
0.000123E0: 3900F990
|
||||
1/0.0: 7F800000
|
||||
-1/0.0: FF800000
|
||||
0.0/0.0: FFC00000
|
||||
|
||||
|
||||
Out module tests.
|
||||
SIZE(INTEGER) = 2
|
||||
|
||||
Testing LONGREAL.
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
1 2 3 4
|
||||
1234567890123456789012345678901234567890
|
||||
1.0D0: 1.0D+000
|
||||
1.1D0: 1.1D+000
|
||||
2.1D0: 2.1D+000
|
||||
|
|
@ -17,9 +45,10 @@ Testing LONGREAL.
|
|||
0.000123D0: 1.23D-004
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
1 2 3 4
|
||||
1234567890123456789012345678901234567890
|
||||
1.0D0: 1.00000D+000
|
||||
1.1D0: 1.10000D+000
|
||||
2.1D0: 2.10000D+000
|
||||
|
|
@ -31,27 +60,29 @@ Testing LONGREAL.
|
|||
0.000123D0: 1.23000D-004
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
1.0D0: 1.000000000000000D+000
|
||||
1.1D0: 1.100000000000000D+000
|
||||
2.1D0: 2.100000000000000D+000
|
||||
-1.1D0: -1.100000000000000D+000
|
||||
1.1D3: 1.100000000000000D+003
|
||||
1.1D-3: 1.100000000000000D-003
|
||||
1.2345678987654321D3: 1.234567898765430D+003
|
||||
0.0: 0.000000000000000D+000
|
||||
0.000123D0: 1.230000000000000D-004
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
1 2 3 4
|
||||
1234567890123456789012345678901234567890
|
||||
1.0D0: 1.0000000000000000D+000
|
||||
1.1D0: 1.1000000000000000D+000
|
||||
2.1D0: 2.1000000000000000D+000
|
||||
-1.1D0: -1.1000000000000000D+000
|
||||
1.1D3: 1.1000000000000000D+003
|
||||
1.1D-3: 1.1000000000000000D-003
|
||||
1.2345678987654321D3: 1.2345678987654300D+003
|
||||
0.0: 0.0000000000000000D+000
|
||||
0.000123D0: 1.2300000000000000D-004
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
|
||||
|
||||
Testing REAL.
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
1 2 3 4
|
||||
1234567890123456789012345678901234567890
|
||||
1.0E0: 1.0E+00
|
||||
1.1E0: 1.1E+00
|
||||
2.1E0: 2.1E+00
|
||||
|
|
@ -63,6 +94,7 @@ Testing REAL.
|
|||
0.000123E0: 1.23E-04
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
|
|
@ -77,31 +109,61 @@ Testing REAL.
|
|||
0.000123E0: 1.230000E-04
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
1.0E0: 1.000000E+00
|
||||
1.1E0: 1.100000E+00
|
||||
2.1E0: 2.100000E+00
|
||||
-1.1E0: -1.100000E+00
|
||||
1.1E3: 1.100000E+03
|
||||
1.1E-3: 1.100000E-03
|
||||
1.2345678987654321E3: 1.234568E+03
|
||||
0.0: 0.000000E+00
|
||||
0.000123E0: 1.230000E-04
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
1 2 3 4
|
||||
1234567890123456789012345678901234567890
|
||||
1.0E0: 1.00000000E+00
|
||||
1.1E0: 1.10000002E+00
|
||||
2.1E0: 2.09999990E+00
|
||||
-1.1E0: -1.10000002E+00
|
||||
1.1E3: 1.10000000E+03
|
||||
1.1E-3: 1.09999999E-03
|
||||
1.2345678987654321E3: 1.23456787E+03
|
||||
0.0: 0.00000000E+00
|
||||
0.000123E0: 1.23000005E-04
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
|
||||
|
||||
--- Testing with Component Pascal variable model ---
|
||||
Real number hex representation.
|
||||
1.0D0: 3FF0000000000000
|
||||
1.1D0: 3FF199999999999A
|
||||
2.1D0: 4000CCCCCCCCCCCD
|
||||
-1.1D0: BFF199999999999A
|
||||
1.1D3: 4091300000000000
|
||||
1.1D-3: 3F5205BC01A36E2F
|
||||
1.2345678987654321D3: 40934A45874103D8
|
||||
0.0: 0000000000000000
|
||||
0.000123D0: 3F201F31F46ED246
|
||||
1/0.0: 7FF0000000000000
|
||||
-1/0.0: FFF0000000000000
|
||||
0.0/0.0: FFF8000000000000
|
||||
|
||||
1.0E0: 3F800000
|
||||
1.1E0: 3F8CCCCD
|
||||
2.1E0: 40066666
|
||||
-1.1E0: BF8CCCCD
|
||||
1.1E3: 44898000
|
||||
1.1E-3: 3A902DE0
|
||||
1.2345678987654321E3: 449A522C
|
||||
0.0: 00000000
|
||||
0.000123E0: 3900F990
|
||||
1/0.0: 7F800000
|
||||
-1/0.0: FF800000
|
||||
0.0/0.0: FFC00000
|
||||
|
||||
|
||||
Out module tests.
|
||||
SIZE(INTEGER) = 4
|
||||
|
||||
Testing LONGREAL.
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
1 2 3 4
|
||||
1234567890123456789012345678901234567890
|
||||
1.0D0: 1.0D+000
|
||||
1.1D0: 1.1D+000
|
||||
2.1D0: 2.1D+000
|
||||
|
|
@ -113,9 +175,10 @@ Testing LONGREAL.
|
|||
0.000123D0: 1.23D-004
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
1 2 3 4
|
||||
1234567890123456789012345678901234567890
|
||||
1.0D0: 1.00000D+000
|
||||
1.1D0: 1.10000D+000
|
||||
2.1D0: 2.10000D+000
|
||||
|
|
@ -127,27 +190,29 @@ Testing LONGREAL.
|
|||
0.000123D0: 1.23000D-004
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
1.0D0: 1.000000000000000D+000
|
||||
1.1D0: 1.100000000000000D+000
|
||||
2.1D0: 2.100000000000000D+000
|
||||
-1.1D0: -1.100000000000000D+000
|
||||
1.1D3: 1.100000000000000D+003
|
||||
1.1D-3: 1.100000000000000D-003
|
||||
1.2345678987654321D3: 1.234567898765430D+003
|
||||
0.0: 0.000000000000000D+000
|
||||
0.000123D0: 1.230000000000000D-004
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
1 2 3 4
|
||||
1234567890123456789012345678901234567890
|
||||
1.0D0: 1.0000000000000000D+000
|
||||
1.1D0: 1.1000000000000000D+000
|
||||
2.1D0: 2.1000000000000000D+000
|
||||
-1.1D0: -1.1000000000000000D+000
|
||||
1.1D3: 1.1000000000000000D+003
|
||||
1.1D-3: 1.1000000000000000D-003
|
||||
1.2345678987654321D3: 1.2345678987654300D+003
|
||||
0.0: 0.0000000000000000D+000
|
||||
0.000123D0: 1.2300000000000000D-004
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
|
||||
|
||||
Testing REAL.
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
1 2 3 4
|
||||
1234567890123456789012345678901234567890
|
||||
1.0E0: 1.0E+00
|
||||
1.1E0: 1.1E+00
|
||||
2.1E0: 2.1E+00
|
||||
|
|
@ -159,6 +224,7 @@ Testing REAL.
|
|||
0.000123E0: 1.23E-04
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
|
|
@ -173,18 +239,20 @@ Testing REAL.
|
|||
0.000123E0: 1.230000E-04
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
1 2 3
|
||||
123456789012345678901234567890
|
||||
1.0E0: 1.000000E+00
|
||||
1.1E0: 1.100000E+00
|
||||
2.1E0: 2.100000E+00
|
||||
-1.1E0: -1.100000E+00
|
||||
1.1E3: 1.100000E+03
|
||||
1.1E-3: 1.100000E-03
|
||||
1.2345678987654321E3: 1.234568E+03
|
||||
0.0: 0.000000E+00
|
||||
0.000123E0: 1.230000E-04
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
1 2 3 4
|
||||
1234567890123456789012345678901234567890
|
||||
1.0E0: 1.00000000E+00
|
||||
1.1E0: 1.10000002E+00
|
||||
2.1E0: 2.09999990E+00
|
||||
-1.1E0: -1.10000002E+00
|
||||
1.1E3: 1.10000000E+03
|
||||
1.1E-3: 1.09999999E-03
|
||||
1.2345678987654321E3: 1.23456787E+03
|
||||
0.0: 0.00000000E+00
|
||||
0.000123E0: 1.23000005E-04
|
||||
1/0.0: Infinity
|
||||
-1/0.0: -Infinity
|
||||
0.0/0.0: -NaN
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,75 @@
|
|||
MODULE outtest;
|
||||
|
||||
IMPORT Out;
|
||||
IMPORT Out, SYSTEM;
|
||||
|
||||
VAR
|
||||
r: REAL;
|
||||
lr: LONGREAL;
|
||||
cw: SYSTEM.INT16;
|
||||
|
||||
PROCEDURE wc(c: CHAR); BEGIN Out.Char(c) END wc;
|
||||
PROCEDURE ws(s: ARRAY OF CHAR); BEGIN Out.String(s) END ws;
|
||||
PROCEDURE wi(i: HUGEINT); BEGIN Out.Int(i,1) END wi;
|
||||
PROCEDURE wl; BEGIN Out.Ln END wl;
|
||||
|
||||
PROCEDURE wh(VAR h: ARRAY OF SYSTEM.BYTE);
|
||||
VAR i: INTEGER; b: SYSTEM.INT8;
|
||||
BEGIN
|
||||
i := SHORT(LEN(h));
|
||||
WHILE i > 0 DO
|
||||
DEC(i); b := SYSTEM.VAL(SYSTEM.INT8, h[i]);
|
||||
IF b DIV 16 MOD 16 < 10 THEN wc(CHR(b DIV 16 MOD 16 + 48)) ELSE wc(CHR(b DIV 16 MOD 16 + 55)) END;
|
||||
IF b MOD 16 < 10 THEN wc(CHR(b MOD 16 + 48)) ELSE wc(CHR(b MOD 16 + 55)) END;
|
||||
END
|
||||
END wh;
|
||||
|
||||
|
||||
(*
|
||||
PROCEDURE -GetFpcw() '__asm__ __volatile__ ("fnstcw %0" : "=m" (outtest_cw))';
|
||||
*)
|
||||
|
||||
|
||||
|
||||
BEGIN
|
||||
(*
|
||||
ws("Floating point control word: "); GetFpcw; wh(cw); wl;
|
||||
wl;
|
||||
*)
|
||||
|
||||
ws("Real number hex representation."); wl;
|
||||
lr := 1.0D0; ws(" 1.0D0: "); wh(lr); wl;
|
||||
lr := 1.1D0; ws(" 1.1D0: "); wh(lr); wl;
|
||||
lr := 2.1D0; ws(" 2.1D0: "); wh(lr); wl;
|
||||
lr := -1.1D0; ws("-1.1D0: "); wh(lr); wl;
|
||||
lr := 1.1D3; ws(" 1.1D3: "); wh(lr); wl;
|
||||
lr := 1.1D-3; ws(" 1.1D-3: "); wh(lr); wl;
|
||||
lr := 1.2345678987654321D3; ws(" 1.2345678987654321D3: "); wh(lr); wl;
|
||||
lr := 0.0; ws(" 0.0: "); wh(lr); wl;
|
||||
lr := 0.000123D0; ws(" 0.000123D0: "); wh(lr); wl;
|
||||
lr := 0.0; lr := 1/lr; ws(" 1/0.0: "); wh(lr); wl;
|
||||
lr := 0.0; lr := -1/lr; ws("-1/0.0: "); wh(lr); wl;
|
||||
lr := 0.0; lr := 0.0D0/lr; ws(" 0.0/0.0: "); wh(lr); wl;
|
||||
wl;
|
||||
r := 1.0E0; ws(" 1.0E0: "); wh(r); wl;
|
||||
r := 1.1E0; ws(" 1.1E0: "); wh(r); wl;
|
||||
r := 2.1E0; ws(" 2.1E0: "); wh(r); wl;
|
||||
r := -1.1E0; ws("-1.1E0: "); wh(r); wl;
|
||||
r := 1.1E3; ws(" 1.1E3: "); wh(r); wl;
|
||||
r := 1.1E-3; ws(" 1.1E-3: "); wh(r); wl;
|
||||
r := 1.2345678987654321E3; ws(" 1.2345678987654321E3: "); wh(r); wl;
|
||||
r := 0.0; ws(" 0.0: "); wh(r); wl;
|
||||
r := 0.000123E0; ws(" 0.000123E0: "); wh(r); wl;
|
||||
r := 0.0; r := 1/r; ws(" 1/0.0: "); wh(r); wl;
|
||||
r := 0.0; r := -1/r; ws("-1/0.0: "); wh(r); wl;
|
||||
r := 0.0; r := 0.0E0/r; ws(" 0.0/0.0: "); wh(r); wl;
|
||||
wl; wl;
|
||||
|
||||
ws("Out module tests."); wl;
|
||||
ws("SIZE(INTEGER) = "); wi(SIZE(INTEGER)); wl; wl;
|
||||
|
||||
ws("Testing LONGREAL."); wl; wl;
|
||||
ws(" 1 2 3"); wl;
|
||||
ws(" 123456789012345678901234567890"); wl;
|
||||
ws(" 1 2 3 4"); wl;
|
||||
ws(" 1234567890123456789012345678901234567890"); wl;
|
||||
ws(" 1.0D0: "); Out.LongReal( 1.0D0, 1); wl;
|
||||
ws(" 1.1D0: "); Out.LongReal( 1.1D0, 1); wl;
|
||||
ws(" 2.1D0: "); Out.LongReal( 2.1D0, 1); wl;
|
||||
|
|
@ -31,9 +83,11 @@ BEGIN
|
|||
ws(" 1/0.0: "); Out.LongReal(lr, 1); wl;
|
||||
lr := 0.0; lr := -1/lr;
|
||||
ws("-1/0.0: "); Out.LongReal(lr, 1); wl;
|
||||
lr := 0.0; lr := 0.0D0/lr;
|
||||
ws(" 0.0/0.0: "); Out.LongReal(lr, 1); wl;
|
||||
wl;
|
||||
ws(" 1 2 3"); wl;
|
||||
ws(" 123456789012345678901234567890"); wl;
|
||||
ws(" 1 2 3 4"); wl;
|
||||
ws(" 1234567890123456789012345678901234567890"); wl;
|
||||
ws(" 1.0D0: "); Out.LongReal( 1.0D0, 12); wl;
|
||||
ws(" 1.1D0: "); Out.LongReal( 1.1D0, 12); wl;
|
||||
ws(" 2.1D0: "); Out.LongReal( 2.1D0, 12); wl;
|
||||
|
|
@ -47,28 +101,32 @@ BEGIN
|
|||
ws(" 1/0.0: "); Out.LongReal(lr, 12); wl;
|
||||
lr := 0.0; lr := -1/lr;
|
||||
ws("-1/0.0: "); Out.LongReal(lr, 12); wl;
|
||||
lr := 0.0; lr := 0.0D0/lr;
|
||||
ws(" 0.0/0.0: "); Out.LongReal(lr, 12); wl;
|
||||
wl;
|
||||
ws(" 1 2 3"); wl;
|
||||
ws(" 123456789012345678901234567890"); wl;
|
||||
ws(" 1.0D0: "); Out.LongReal( 1.0D0, 30); wl;
|
||||
ws(" 1.1D0: "); Out.LongReal( 1.1D0, 30); wl;
|
||||
ws(" 2.1D0: "); Out.LongReal( 2.1D0, 30); wl;
|
||||
ws("-1.1D0: "); Out.LongReal(-1.1D0, 30); wl;
|
||||
ws(" 1.1D3: "); Out.LongReal( 1.1D3, 30); wl;
|
||||
ws(" 1.1D-3: "); Out.LongReal( 1.1D-3, 30); wl;
|
||||
ws(" 1.2345678987654321D3: "); Out.LongReal( 1.2345678987654321D3, 30); wl;
|
||||
ws(" 0.0: "); Out.LongReal(0.0, 30); wl;
|
||||
ws(" 0.000123D0: "); Out.LongReal(0.000123D0, 30); wl;
|
||||
ws(" 1 2 3 4"); wl;
|
||||
ws(" 1234567890123456789012345678901234567890"); wl;
|
||||
ws(" 1.0D0: "); Out.LongReal( 1.0D0, 40); wl;
|
||||
ws(" 1.1D0: "); Out.LongReal( 1.1D0, 40); wl;
|
||||
ws(" 2.1D0: "); Out.LongReal( 2.1D0, 40); wl;
|
||||
ws("-1.1D0: "); Out.LongReal(-1.1D0, 40); wl;
|
||||
ws(" 1.1D3: "); Out.LongReal( 1.1D3, 40); wl;
|
||||
ws(" 1.1D-3: "); Out.LongReal( 1.1D-3, 40); wl;
|
||||
ws(" 1.2345678987654321D3: "); Out.LongReal( 1.2345678987654321D3, 40); wl;
|
||||
ws(" 0.0: "); Out.LongReal(0.0, 40); wl;
|
||||
ws(" 0.000123D0: "); Out.LongReal(0.000123D0, 40); wl;
|
||||
lr := 0.0; lr := 1/lr;
|
||||
ws(" 1/0.0: "); Out.LongReal(lr, 30); wl;
|
||||
ws(" 1/0.0: "); Out.LongReal(lr, 40); wl;
|
||||
lr := 0.0; lr := -1/lr;
|
||||
ws("-1/0.0: "); Out.LongReal(lr, 30); wl;
|
||||
ws("-1/0.0: "); Out.LongReal(lr, 40); wl;
|
||||
lr := 0.0; lr := 0.0D0/lr;
|
||||
ws(" 0.0/0.0: "); Out.LongReal(lr, 40); wl;
|
||||
wl; wl; wl;
|
||||
|
||||
|
||||
ws("Testing REAL."); wl; wl;
|
||||
ws(" 1 2 3"); wl;
|
||||
ws(" 123456789012345678901234567890"); wl;
|
||||
ws(" 1 2 3 4"); wl;
|
||||
ws(" 1234567890123456789012345678901234567890"); wl;
|
||||
ws(" 1.0E0: "); Out.Real( 1.0E0, 1); wl;
|
||||
ws(" 1.1E0: "); Out.Real( 1.1E0, 1); wl;
|
||||
ws(" 2.1E0: "); Out.Real( 2.1E0, 1); wl;
|
||||
|
|
@ -82,6 +140,8 @@ BEGIN
|
|||
ws(" 1/0.0: "); Out.Real(r, 1); wl;
|
||||
r := 0.0; r := -1/r;
|
||||
ws("-1/0.0: "); Out.Real(r, 1); wl;
|
||||
r := 0.0; r := 0.0E0/r;
|
||||
ws(" 0.0/0.0: "); Out.Real(r, 1); wl;
|
||||
wl;
|
||||
ws(" 1 2 3"); wl;
|
||||
ws(" 123456789012345678901234567890"); wl;
|
||||
|
|
@ -98,22 +158,26 @@ BEGIN
|
|||
ws(" 1/0.0: "); Out.Real(r, 12); wl;
|
||||
r := 0.0; r := -1/r;
|
||||
ws("-1/0.0: "); Out.Real(r, 12); wl;
|
||||
r := 0.0; r := 0.0E0/r;
|
||||
ws(" 0.0/0.0: "); Out.Real(r, 12); wl;
|
||||
wl;
|
||||
ws(" 1 2 3"); wl;
|
||||
ws(" 123456789012345678901234567890"); wl;
|
||||
ws(" 1.0E0: "); Out.Real( 1.0E0, 30); wl;
|
||||
ws(" 1.1E0: "); Out.Real( 1.1E0, 30); wl;
|
||||
ws(" 2.1E0: "); Out.Real( 2.1E0, 30); wl;
|
||||
ws("-1.1E0: "); Out.Real(-1.1E0, 30); wl;
|
||||
ws(" 1.1E3: "); Out.Real( 1.1E3, 30); wl;
|
||||
ws(" 1.1E-3: "); Out.Real( 1.1E-3, 30); wl;
|
||||
ws(" 1.2345678987654321E3: "); Out.Real( 1.2345678987654321E3, 30); wl;
|
||||
ws(" 0.0: "); Out.Real(0.0, 30); wl;
|
||||
ws(" 0.000123E0: "); Out.Real(0.000123E0, 30); wl;
|
||||
ws(" 1 2 3 4"); wl;
|
||||
ws(" 1234567890123456789012345678901234567890"); wl;
|
||||
ws(" 1.0E0: "); Out.Real( 1.0E0, 40); wl;
|
||||
ws(" 1.1E0: "); Out.Real( 1.1E0, 40); wl;
|
||||
ws(" 2.1E0: "); Out.Real( 2.1E0, 40); wl;
|
||||
ws("-1.1E0: "); Out.Real(-1.1E0, 40); wl;
|
||||
ws(" 1.1E3: "); Out.Real( 1.1E3, 40); wl;
|
||||
ws(" 1.1E-3: "); Out.Real( 1.1E-3, 40); wl;
|
||||
ws(" 1.2345678987654321E3: "); Out.Real( 1.2345678987654321E3, 40); wl;
|
||||
ws(" 0.0: "); Out.Real(0.0, 40); wl;
|
||||
ws(" 0.000123E0: "); Out.Real(0.000123E0, 40); wl;
|
||||
r := 0.0; r := 1/r;
|
||||
ws(" 1/0.0: "); Out.Real(r, 30); wl;
|
||||
ws(" 1/0.0: "); Out.Real(r, 40); wl;
|
||||
r := 0.0; r := -1/r;
|
||||
ws("-1/0.0: "); Out.Real(r, 30); wl;
|
||||
ws("-1/0.0: "); Out.Real(r, 40); wl;
|
||||
r := 0.0; r := 0.0E0/r;
|
||||
ws(" 0.0/0.0: "); Out.Real(r, 40); wl;
|
||||
wl;
|
||||
|
||||
END outtest.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue