For Programmers: Free Programming Magazines  


Home > Archive > Cobol > March 2007 > HIGHEST-ALGEBRAIC and LOWEST-ALGEBRAIC (was: Re: Dynamically ...)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author HIGHEST-ALGEBRAIC and LOWEST-ALGEBRAIC (was: Re: Dynamically ...)
Rick Smith

2007-03-26, 9:55 pm


"Roger While" <simrw@sim-basis.de> wrote in message
news:eu91il$jmf$00$1@news.t-online.com...
> Top post - Bill does it as well, so do not shout.
> Has the advantage that :
> a) Does not rely on compiler implemtation of 31 digits
> Compilers can implement more/less digits. (OC goes to 36)
> b) Does not reley on TRUNC rules.
>
> The problem that I see is what (logically) is one trying
> to achieve in moving a maximum/minimum from one format to antother.
> (Very strange these 2002/2008 functions)


Page 827, FDIS 1989:2002, F.2 Substantive changes
not affecting existing programs,

"64) HIGHEST-ALGEBRAIC and LOWEST-ALGEBRAIC
functions. The HIGHEST-ALGEBRAIC and
LOWEST-ALGEBRAIC functions provide the ability to
manipulate numeric data items in a manner similar to
the means that HIGH-VALUES and LOW-VALUES
permit with alphanumeric data items, but without the risks
of the data incompatibilities associated with those figurative
constants."

Perhaps, they are useful for something like, ...

READ Customer-File NEXT
AT END
MOVE HIGHEST-ALGEBRAIC (Customer-ID)
TO Customer-ID
END-READ

Where "Customer-ID" is numeric and valid values
do not include the highest or lowest algebraic values
for the PICTURE clause.

Or, ...

COMPUTE Balance-Due = HIGHEST-ALGEBRAIC (Balance-Due)
START Customer-File KEY IS LESS THAN Balance-Due
END-START
READ Customer-File PREVIOUS
AT END
MOVE LOWEST-ALGEBRAIC (Balance-Due)
TO Balance-Due
END-READ



Roger While

2007-03-27, 3:55 am

I know that FLOAT-xxx are implementor defined but I wonder
what these functions should return for FLOAT-xxx fields and how
to programatically achieve this.

"Rick Smith" <ricksmith@mfi.net> schrieb im Newsbeitrag
news:130gjnv8uc1uadb@corp.supernews.com...
>
> "Roger While" <simrw@sim-basis.de> wrote in message
> news:eu91il$jmf$00$1@news.t-online.com...
>
> Page 827, FDIS 1989:2002, F.2 Substantive changes
> not affecting existing programs,
>
> "64) HIGHEST-ALGEBRAIC and LOWEST-ALGEBRAIC
> functions. The HIGHEST-ALGEBRAIC and
> LOWEST-ALGEBRAIC functions provide the ability to
> manipulate numeric data items in a manner similar to
> the means that HIGH-VALUES and LOW-VALUES
> permit with alphanumeric data items, but without the risks
> of the data incompatibilities associated with those figurative
> constants."
>
> Perhaps, they are useful for something like, ...
>
> READ Customer-File NEXT
> AT END
> MOVE HIGHEST-ALGEBRAIC (Customer-ID)
> TO Customer-ID
> END-READ
>
> Where "Customer-ID" is numeric and valid values
> do not include the highest or lowest algebraic values
> for the PICTURE clause.
>
> Or, ...
>
> COMPUTE Balance-Due = HIGHEST-ALGEBRAIC (Balance-Due)
> START Customer-File KEY IS LESS THAN Balance-Due
> END-START
> READ Customer-File PREVIOUS
> AT END
> MOVE LOWEST-ALGEBRAIC (Balance-Due)
> TO Balance-Due
> END-READ
>
>
>



Rick Smith

2007-03-27, 7:55 am


"Roger While" <simrw@sim-basis.de> wrote in message
news:euahkq$2ig$02$1@news.t-online.com...
> I know that FLOAT-xxx are implementor defined but I wonder
> what these functions should return for FLOAT-xxx fields and how
> to programatically achieve this.


For an underlying C or C++ implementation, ...
-----
#include <float.h>

float highest_algebraic_float_short () {
return (FLT_MAX);
}
float lowest_algebraic_float_short () {
return (-FLT_MAX);
}
double highest_algebraic_float_long () {
return (DBL_MAX);
}
double lowest_algebraic_float_long () {
return (-DBL_MAX);
}
long double highest_algebraic_float_extended () {
return (LDBL_MAX);
}
long double lowest_algebraic_float_extended () {
return (-LDBL_MAX);
}
-----
Or something like this, should do it.

Values from Microsoft Visual C++ 5.0 are:

#define FLT_MAX 3.402823466e+38F /* max value */
#define DBL_MAX 1.7976931348623158e+308 /* max value */
#define LDBL_MAX 1.189731495357231765e+4932L /* max value */



Roger While

2007-03-27, 6:55 pm

Is float.h a POSIX standard ?

And when not defined on a particular mc
what then ?


"Rick Smith" <ricksmith@mfi.net> schrieb im Newsbeitrag
news:130i39dj89ohrb2@corp.supernews.com...
>
> "Roger While" <simrw@sim-basis.de> wrote in message
> news:euahkq$2ig$02$1@news.t-online.com...
>
> For an underlying C or C++ implementation, ...
> -----
> #include <float.h>
>
> float highest_algebraic_float_short () {
> return (FLT_MAX);
> }
> float lowest_algebraic_float_short () {
> return (-FLT_MAX);
> }
> double highest_algebraic_float_long () {
> return (DBL_MAX);
> }
> double lowest_algebraic_float_long () {
> return (-DBL_MAX);
> }
> long double highest_algebraic_float_extended () {
> return (LDBL_MAX);
> }
> long double lowest_algebraic_float_extended () {
> return (-LDBL_MAX);
> }
> -----
> Or something like this, should do it.
>
> Values from Microsoft Visual C++ 5.0 are:
>
> #define FLT_MAX 3.402823466e+38F /* max value */
> #define DBL_MAX 1.7976931348623158e+308 /* max value */
> #define LDBL_MAX 1.189731495357231765e+4932L /* max value */
>
>
>



Rick Smith

2007-03-27, 6:55 pm


"Roger While" <simrw@sim-basis.de> wrote in message
news:eubes7$181$03$1@news.t-online.com...
> Is float.h a POSIX standard ?


I don't know! However, it is in standard C (ISO 9899:1990).

Where FLT_MAX, DBL_MAX, and LDBL_MAX are
present they are defined as, at least, 1E+37 for all sizes
and the implementor of the C compiler is required to
support floating-point to this limit to be conforming.

> And when not defined on a particular mc
> what then ?


A COBOL implementation need not support floating-point.

Page 696, FDIS 19892002, B.3 Processor-dependent
language element list, ...

"5) The usages FLOAT-SHORT, FLOAT-LONG, and
FLOAT-EXTENDED are dependent upon the availability
of a suitable computer architecture for floating-point data
formats."

If "not defined on a particular mc" means "not available",
then the usages need not be implemented.

[color=darkred]
> "Rick Smith" <ricksmith@mfi.net> schrieb im Newsbeitrag
> news:130i39dj89ohrb2@corp.supernews.com...



Rick Smith

2007-03-27, 6:55 pm


"Rick Smith" <ricksmith@mfi.net> wrote in message
news:130il0lm4fsmd3c@corp.supernews.com...
>
> "Roger While" <simrw@sim-basis.de> wrote in message
> news:eubes7$181$03$1@news.t-online.com...
>
> I don't know! However, it is in standard C (ISO 9899:1990).
>
> Where FLT_MAX, DBL_MAX, and LDBL_MAX are
> present they are defined as, at least, 1E+37 for all sizes
> and the implementor of the C compiler is required to
> support floating-point to this limit to be conforming.


As an afterthought, I looked at <float.h> for a
"freestanding" implementation of C for an Intel 8051
microprocessor and found the following.
-----
#define FLT_MAX 3.40282e38
#define DBL_MAX FLT_MAX
#define LDBL_MAX FLT_MAX
-----



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com