Code Comments
Programming Forum and web based access to our favorite programming groups."Robert Wagner" <robert.deletethis@wagner.net> wrote in message news:40f39e89.131187942@news.optonline.net... > "Chuck Stevens" <charles.stevens@unisys.com> wrote: > <snip> > > > That must be about packed decimal. Everything is valid in binary. > Not true. The 2002 Standard *defines* the IF NUMERIC class test against a BINARY (or COMPUTATIONAL - or PACKED-DECIMAL) field as *only* passing when the data *matches* the PICTURE (and usage). Therefore, an IF NUMERIC class test aga inst a BINARY-CHAR (new USAGE) field will (always?) pass as any bit combination matches the USAGE (and there is NO picture clause), for a 02 Num-Field Pic S99 Binary. field if it as an "algebraic" (using the term loosely) value of 100 - even i f it "fits" in the field, it would FAIL an IF NUMERIC class test. Personally, I was never certain this was the right way for the definition to be made, but it IS what the Standard says. Of course any compiler that support s a "NOTRUNC" compiler option (as most? many? do) is already running in NON-Stan dard mode - and can do whatever it wants with the "new" IF NUMERIC class test in that environment. It only needs to "match" the Standard when "standard conformi ng" options are in effect. -- Bill Klein wmklein <at> ix.netcom.com
Post Follow-up to this message"William M. Klein" <wmklein@nospam.netcom.com> wrote: >The 2002 Standard *defines* the IF NUMERIC class test against a BINARY (or >COMPUTATIONAL - or PACKED-DECIMAL) field as *only* passing when the data >*matches* the PICTURE (and usage). Therefore, an IF NUMERIC class test against >a BINARY-CHAR (new USAGE) field will (always?) pass as any bit combination >matches the USAGE (and there is NO picture clause), for a > 02 Num-Field Pic S99 Binary. > >field if it as an "algebraic" (using the term loosely) value of 100 - even if[/colo r] it >"fits" in the field, it would FAIL an IF NUMERIC class test. Can a conforming program compare Num-Field to an out-of-range value? If Num-Field less than 100 and greater than -100 Perform Good-Number End-If Would an optimizer discard the following condition and make the Perform unconditional? If Num-Field not greater than 99 and not less than -99 Perform Good-Number End-If
Post Follow-up to this messageA conforming compiler must allow the comparisons; it could (but is not requi red to) allow its optimizer to make the loop unconditional WHEN running in "Stan dard conforming mode". (Again, many/most compilers have a NOTRUNC - or equivalen t option for which these statements are NOT true). FYI, Also of semi-relevance are the new HIGHEST-ALGEBRAIC and LOWEST-ALGEBRAIC intrinsic functions which you may want to look at in the 2002 Standard. -- Bill Klein wmklein <at> ix.netcom.com "Robert Wagner" <robert.deletethis@wagner.net> wrote in message news:40f40a02.158705113@news.optonline.net... > "William M. Klein" <wmklein@nospam.netcom.com> wrote: > > against > it > > Can a conforming program compare Num-Field to an out-of-range value? > > If Num-Field less than 100 and greater than -100 > Perform Good-Number > End-If > > Would an optimizer discard the following condition and make the Perform > unconditional? > > If Num-Field not greater than 99 and not less than -99 > Perform Good-Number > End-If
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.