Home Technique Digital data

Digital data



Definedigitaldata

DigitaldataitemsaredefinedbythePICTUREclause.Each9inthedatadescriptionrepresentsadecimaldigit.

Characterswithspecialmeaningsthatcanappearare:Pindicatesleading0andtrailing0Sindicator,plusorminussignVimpliesadecimalpoint

DataisaboutcertainaspectsAsetofnumbers.

Displaydigitaldata

Inordertomakedigitaldataeasiertoreadwhendisplayingandprinting,youcanuseeditflags(suchas:decimalpoint,comma,dollarsignanddebitsignandcreditsign)Formatnumericdataitems.

Forexample,Edited-priceistheediteddigitaldataiteminthefollowingcode:

05PricePic9(5)v99.

05Edited-pricePic$zz,zz9.99.

...

MovePriceToEdited-price

DisplayEdited-price

MoveEdited-pricetoPrice

DisplayPrice

Controlthestorageofdigitaldata

ThedigitaldataintheCOBOLprogramcanbestoredinthefollowingformat:Externaldecimal(USAGEDISPLAY)ExternalFloatingPoint(USAGEDISPLAY)InternalDecimal(USAGEPACKED-DECIMAL)Binary(USAGEBINARY)LocalBinary(USAGECOMP-5)InternalFloatingPoint(USAGECOMP-1,USAGECOMP-2)

COMPandCOMP-4areequivalenttoBINARY(binary),andCOMP-3isequivalentto(packeddecimal)PACKED-DECIMALCOMP.

Arithmeticoperations

OBNOLarithmeticoperationshavethefollowingmethods:COMPUTE,ADD,SUBTRACT,MULTIPLY,andDIVIDEstatements.Servicesthatcanbecalledinthedigitalbuilt-infunctionlanguageenvironment

4.4.1ArithmeticstatementCOMPTEstatementassignsthevalueofanexpressiontooneormoredataitems.TheCOMPUTEstatementcanbeusedtoeasilycombinearithmeticoperations,andisnotsubjecttoresultstoragerestrictionssuchasADD,SUBSTRACT,MULTIPLY,andDIVIDEstatements.

4.4.1.1ADDstatementADDsyntax1:

ADDidentifier-1,identifier-2,...TOidentifier-n[ROUNDED]

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-ADD]

Example:

ADDNUM1TONUM2.

ADDNUM1,10TONUM2.

ADDNUM1,NUM2TONUM3ONSIZEERRORPERFORM100-ERROR.

ADDSyntax2:

ADDidentifier-1,identifier-2,…[TO]identifier-nGIVINGidentifier-m[ROUNDED]

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-ADD]

Example:

ADDNUM1TONUM2GIVINGNUM3.

ADDNUM1,NUM2GIVINGNUM3.

ADDNUM1,10TONUM2GIVINGNUM3.

ADDSyntax3:

ADDCORRidentifier-1TOidentifier-2[ROUNDED]

[ONSIZEERRORstatement-1

[NOTONSIZEERRORstatement-2][END-ADD]

Example:

03CURRENT-MONTH.

05PAYPIC9(3)V9(2).

05TAXPIC9(2)V9(2).

03YTD.

05PAYPIC9(3)V9(2).

05TAXPIC9(2)V9(2).

p>

ADDCORRCURRENT-MONTHTOYTD.

4.4.1.2SUBTRACTstatementSUBTRACTsyntax1:

SUBTRACTidentifier-1,identifier-2,…FROMidentifier-n

[ROUNDED]

[ONSIZEERRORstatement-1

[NOTONSIZEERRORstatement-2]

[END-SUBTRACT]

Example:

SUBTRACTNUM1FROMNUM2.

SUBTRACTsyntax2:

SUBTRACTidentifier-1identifier-2,…FROMidentifier-n

GIVINGidentifier-m[ROUNDED]

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-SUBTRACT]

Example:

SUBTRACTNUM1FROMNUM2GIVINGNUM3.

SUBTRACTsyntax3:

SUBTRACTCORRidentifier-1FROMidentifier-2

[ROUNDED]

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-SUBTRACT]

Example:

Digital data

SUBTRACTCORRREC1FROMREC2.

4.4.1.3MULTIPLYstatementMULTIPLYsyntax1:

MULTIPLYidentifier-1BYidentifier-2

[ROUNDED]

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-MULTIPLY]

Example:

MULTIPLYNUM1BYNUM2.

MULTIPLYsyntax2:

MULTIPLYidentifier-1BYidentifier-2

GIVINGidentifier-3

[ROUNDED]

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-MULTIPLY]

Example:

MULTIPLYNUM1BYNUM2GIVINGNUM3.

4.4.1.4DIVIDEstatementDIVIDEsyntax1:

DIVIDEidentifier-1INTOidentifier-2

[ROUNDED]

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-DIVIDE]

Example:

DIVIDENUM1INTONUM2.

DIVIDEsyntax2:

DIVIDEidentifier-1INTOidentifier-2

GIVINGidentifier-3

[ROUNDED]

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-DIVIDE]

Example:

DIVIDENUM1INTONUM2GIVINGNUM3.

DIVIDEsyntax3:

DIVIDEidentifier-1BYidentifier-2

GIVINGidentifier-3

[ROUNDED]

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-DIVIDE]

Example:

DIVIDENUM1BYNUM2GIVINGNUM3.

DIVIDEsyntax4:

DIVIDEidentifier-1INTOidentifier-2

GIVINGidentifier-3

[ROUNDED]

REMAINDERidentifier-4

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-DIVIDE]

Example:

DIVIDENUM1INTONUM2GIVINGNUM3REMAINDERNUM4.

DIVIDEsyntax5:

DIVIDEidentifier-1BYidentifier-2

GIVINGidentifier-3

[ROUNDED]

REMAINDERidentifier-4

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-DIVIDE]

Example:

DIVIDENUM1BYNUM2GIVINGNUM3REMAINDERNUM4.

4.4.1.5COMPUTEstatementCOMPUTEsyntax:

COMPUTEidentifier-1[ROUNDED],identifier-2[ROUNDED],...

=arithmetic-expression

[ONSIZEERRORstatement-1]

[NOTONSIZEERRORstatement-2]

[END-COMPUTE]

Example:

COMPUTERESULT=NUM1*NUM2+NUM3-NUM4.

4.4.2ArithmeticexpressionallowsnumericdataitemstoappearPlacescanbereplacedwitharithmeticexpressions.

Arithmeticexpressionscanhavepositiveandnegativesigns(+,-),powerexponentsigns(**),divisionormultiplicationsigns(/,*)andplusorminussigns(+,-).

4.4.3Digitalbuilt-infunctionsDigitalbuilt-infunctionscanonlyappearwherenumericexpressionsareallowed.

Thenumberbuilt-infunctionreturnsasignedvalue.Thefunctionitselfcanberegardedasatemporarydigitaldataitem.

Herearesomedigitalbuilt-infunctions:Numberprocessing:LENGTH,MAX,MIN,NUMVAL,NUMVAL-C,ORD-MAX,ORD-MINDateandtime:CURRENT-DATE,DATE-TO-YYYYMMDD,…EtcMathematics:INTEGER,LOG,SUM,SIN,COS,MOD,…etc.

Example:

COMPUTEX=LENGTH(RECORD).

COMPUTEY=MAX(X,Y).

This article is from the network, does not represent the position of this station. Please indicate the origin of reprint
TOP