HIGH Decimal ?

This is a discussion on HIGH Decimal ? within the pl1 forums in Programming Languages category; I think I've looked everywhere with no success. I'm want a BIF that does for FIXED DECIMAL what HIGH (or LOW) does for binary. I of course could tediously hand-build something perhaps using GENERIC. But something less cumbersome would be preferable. TIA, Walter Rue...

Go Back   Application Development Forum > Programming Languages > pl1

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 04-11-2008, 09:41 PM
WalterR
Guest
 
Default HIGH Decimal ?

I think I've looked everywhere with no success. I'm want a BIF that
does for FIXED DECIMAL what HIGH (or LOW) does for binary. I of course
could tediously hand-build something perhaps using GENERIC. But
something less cumbersome would be preferable.

TIA,

Walter Rue
Reply With Quote
  #2  
Old 04-11-2008, 11:28 PM
James J. Weinkam
Guest
 
Default Re: HIGH Decimal ?

WalterR wrote:
> I think I've looked everywhere with no success. I'm want a BIF that
> does for FIXED DECIMAL what HIGH (or LOW) does for binary. I of course
> could tediously hand-build something perhaps using GENERIC. But
> something less cumbersome would be preferable.
>


I think you must be confused. HIGH and LOW return respectively a string
of all '00'X or 'FF'X characters where the length of the string is the
argument of the function.
Reply With Quote
  #3  
Old 04-12-2008, 12:33 AM
John W. Kennedy
Guest
 
Default Re: HIGH Decimal ?

WalterR wrote:
> I think I've looked everywhere with no success. I'm want a BIF that
> does for FIXED DECIMAL what HIGH (or LOW) does for binary. I of course
> could tediously hand-build something perhaps using GENERIC. But
> something less cumbersome would be preferable.


I don't understand. Do you want to stuff the field with illegal data
that will make your program blow up (in which case you can use UNSPEC)?
Or do you just want nines (in which case you can just use nines)?

DECLARE NATIONAL_DEBT FIXED DECIMAL(15,2);
...
NATIONAL_DEBT = 9999999999999.99;

Or, if you're concerned about future program changes:

DECLARE NATIONAL_DEBT FIXED DECIMAL(15,2);
DECLARE MAX_NATIONAL_DEBT FIXED DECIMAL(15,2) VALUE (9999999999999.99);
...
NATIONAL_DEBT = MAX_NATIONAL_DEBT;

Substitute STATIC INITIAL(...) for VALUE(...) on older compilers.


--
John W. Kennedy
"The blind rulers of Logres
Nourished the land on a fallacy of rational virtue."
-- Charles Williams. "Taliessin through Logres: Prelude"
Reply With Quote
  #4  
Old 04-12-2008, 09:56 AM
WalterR
Guest
 
Default Re: HIGH Decimal ?

John W. Kennedy wrote:

> WalterR wrote:
>
>> I think I've looked everywhere with no success. I'm want a BIF that
>> does for FIXED DECIMAL what HIGH (or LOW) does for binary. I of
>> course could tediously hand-build something perhaps using GENERIC.
>> But something less cumbersome would be preferable.

>
>
> I don't understand. Do you want to stuff the field with illegal data
> that will make your program blow up (in which case you can use
> UNSPEC)? Or do you just want nines (in which case you can just use
> nines)?
>
> DECLARE NATIONAL_DEBT FIXED DECIMAL(15,2);
> ...
> NATIONAL_DEBT = 9999999999999.99;
>
> Or, if you're concerned about future program changes:
>
> DECLARE NATIONAL_DEBT FIXED DECIMAL(15,2);
> DECLARE MAX_NATIONAL_DEBT FIXED DECIMAL(15,2) VALUE (9999999999999.99);
> ...
> NATIONAL_DEBT = MAX_NATIONAL_DEBT;
>
> Substitute STATIC INITIAL(...) for VALUE(...) on older compilers.
>
>

I just want all nines, that is, the HIGHest value a given FIXED DECIMAL
field can have. Instead of counting the nines one-by-one (and worrying
about a mis-count), I want a BIF or equ that will automatically fill
every position. UNSPEC and HIGH would fill with '00'X and are obviously
inapplicable. By the way, I see something along these lines for FLOAT
DECIMAL; but I want this for FIXED fields.

Thanks,
Reply With Quote
  #5  
Old 04-12-2008, 02:33 PM
James J. Weinkam
Guest
 
Default Re: HIGH Decimal ?

James J. Weinkam wrote:
> WalterR wrote:
>> I think I've looked everywhere with no success. I'm want a BIF that
>> does for FIXED DECIMAL what HIGH (or LOW) does for binary. I of
>> course could tediously hand-build something perhaps using GENERIC.
>> But something less cumbersome would be preferable.
>>

>
> I think you must be confused. HIGH and LOW return respectively a string
> of all '00'X or 'FF'X characters where the length of the string is the
> argument of the function.


Sorry to respond to my own post, but I obviously typed that backwards.
LOW returns '00'x and HIGH returns 'FF'x.
Reply With Quote
  #6  
Old 04-13-2008, 09:38 AM
robin
Guest
 
Default Re: HIGH Decimal ?

"WalterR" <wsrue@verizon.net> wrote in message news:WqULj.74$Ho5.37@trnddc01...
> I think I've looked everywhere with no success. I'm want a BIF that
> does for FIXED DECIMAL what HIGH (or LOW) does for binary. I of course
> could tediously hand-build something perhaps using GENERIC. But
> something less cumbersome would be preferable.
>
> TIA,
> Walter Rue


I think that you mean HUGE.

There is no corresponding function for fixed decimal.

Have you tried doing that using the precision values of the variable
in question?

Also, as pointed out by another, INITIAL can be used to set maximum value.

As a non-portable solution (which I am reluctant to put forward,
because the above provides an adequate solution) :

DCL NINES FIXED DEC (15) STATIC INIT (999999999999999);

UNSPEC(D) = SUBSTR(UNSPEC (NINES), 4*16-LENGTH(UNSPEC(D))+1 );

which is valid provided that the precision p of D is odd.

I can't say that I've ever needed the maximum value --
if a value exceeds the maximum, the FIXEDOVERFLOW or SIZE condition is raised.

If you want to set storage to a value that will cause an interrupt
then use the compiler option DEFAULT (INITFILL('11')) or DEFAULT (INITFILL('BB')).
That is good for detecting uninitialized decimal values!



Reply With Quote
  #7  
Old 04-13-2008, 01:29 PM
William M. Klein
Guest
 
Default Re: HIGH Decimal ?

<JOKE>

Well you could just call a COBOL program that has the 2002 ISO Standard
intrinsic functions:
HIGHEST-Algebraic
or
LOWEST-Algebraic

This intrinsic functions return the "highest" or "lowest" numeric value that can
be held within a field based on the picture string. These pay attention to
decimal point, signed or non-signed, editing symbols, etc. (regardless of usage,
binary, packed-decimal, display, national, floating-point, etc)

I *think* this is what you are asking for in PL/I.

--
Bill Klein
wmklein <at> ix.netcom.com
"WalterR" <wsrue@verizon.net> wrote in message news:WqULj.74$Ho5.37@trnddc01...
>I think I've looked everywhere with no success. I'm want a BIF that does for
>FIXED DECIMAL what HIGH (or LOW) does for binary. I of course could tediously
>hand-build something perhaps using GENERIC. But something less cumbersome
>would be preferable.
>
> TIA,
>
> Walter Rue



Reply With Quote
  #8  
Old 04-13-2008, 02:11 PM
James J. Weinkam
Guest
 
Default Re: HIGH Decimal ?

robin wrote:
> "WalterR" <wsrue@verizon.net> wrote in message news:WqULj.74$Ho5.37@trnddc01...
>> I think I've looked everywhere with no success. I'm want a BIF that
>> does for FIXED DECIMAL what HIGH (or LOW) does for binary. I of course
>> could tediously hand-build something perhaps using GENERIC. But
>> something less cumbersome would be preferable.
>>
>> TIA,
>> Walter Rue

>
> I think that you mean HUGE.
>
> There is no corresponding function for fixed decimal.
>
> Have you tried doing that using the precision values of the variable
> in question?
>
> Also, as pointed out by another, INITIAL can be used to set maximum value.
>
> As a non-portable solution (which I am reluctant to put forward,
> because the above provides an adequate solution) :
>
> DCL NINES FIXED DEC (15) STATIC INIT (999999999999999);
>
> UNSPEC(D) = SUBSTR(UNSPEC (NINES), 4*16-LENGTH(UNSPEC(D))+1 );
>
> which is valid provided that the precision p of D is odd.
>
> I can't say that I've ever needed the maximum value --
> if a value exceeds the maximum, the FIXEDOVERFLOW or SIZE condition is raised.
>
> If you want to set storage to a value that will cause an interrupt
> then use the compiler option DEFAULT (INITFILL('11')) or DEFAULT (INITFILL('BB')).
> That is good for detecting uninitialized decimal values!
>
>
>

The OP didn't say why he wanted these values, but a common reason for
wanting the algebraically largest or smallest possible value is to
initialize a minimization or maximization algorithm. When the values to
be minimized or maximized over are available at the time of
initialization, an even simpler method is to initialize to the first
value; but this fails if the set of values is empty.
Reply With Quote
  #9  
Old 04-13-2008, 10:16 PM
robin
Guest
 
Default Re: HIGH Decimal ?

"James J. Weinkam" <jjw@cs.sfu.ca> wrote in message news:n1sMj.9963$682.9422@edtnps90...

> The OP didn't say why he wanted these values, but a common reason for
> wanting the algebraically largest or smallest possible value is to
> initialize a minimization or maximization algorithm.


MIN is available for that, as is MAX.

> When the values to
> be minimized or maximized over are available at the time of
> initialization, an even simpler method is to initialize to the first
> value; but this fails if the set of values is empty.


As I said, I rarely found the need for the maximum value.
In olden days when end of file was unreliable or non-existent,
all nines was commonly used, but diehards continued to use
99999 and ZZZZZ long after it became unnecessary.

The largest magnitude value can be determined readily enough if required,
and of course, setting a fixed-point decimal variable to that value is trivial,
as we have seen.


Reply With Quote
  #10  
Old 04-14-2008, 02:27 AM
James J. Weinkam
Guest
 
Default Re: HIGH Decimal ?

robin wrote:
> "James J. Weinkam" <jjw@cs.sfu.ca> wrote in message news:n1sMj.9963$682.9422@edtnps90...
>
>> The OP didn't say why he wanted these values, but a common reason for
>> wanting the algebraically largest or smallest possible value is to
>> initialize a minimization or maximization algorithm.

>
> MIN is available for that, as is MAX.


Perhaps I did not make myself clear.

Consider a possibly empty list of values. We wish to find mn and mx, the
smallest and largest values in the list respectively. What should mn amd
mx be initialized to so that we can examine each element in turn and
come up with the correct answer? The answer is that mn should be
initialized to the largest representable value and mx to the smallest.

At the end of the day, if the list was empty mn and mx will still have
their initial values and mx will be less then mn. If the list contains
any values then mn will be less than or equal to mx and mn will be the
smallest value that occurred and mx the largest. This will be true even
if some of the values in the list were equal to either the smallest or
largest representable value.

The min and max builtin functions could be used in this algorithm but a
simple if statement works equally well and is at least as efficient.
Moreover, their use does not obviate the need to initialize mn and mx as
described. Of course, the need to initialize mn and mx can be avoided
by introducing an initialized variable that indicates whether any values
have been processed yet -- either a counter or a bit will do. However
this variable needs to be checked on each iteration and the first
iteration needs to be handled differently from the rest. I for one
consider resorting unnecessarily to such a variable a blemish.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:16 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.