IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convert a negative value into positive value


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ys_more

New User


Joined: 21 Jun 2005
Posts: 5

PostPosted: Tue Nov 29, 2005 4:36 pm
Reply with quote

Hi , I want to convert a negative value into positive value . Is there any intrinsic function available. do we have -- as valid operator in cobol
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Nov 30, 2005 5:23 am
Reply with quote

ys_more,

Not that I know of, and the coding to do it in cobol is pretty complex.
Code:

IF VE < 0
THEN
    MULTIPLY VE BY -1
END-IF.
icon_smile.gif
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Dec 02, 2005 8:26 am
Reply with quote

I assume your field is part of a file rec that you're reading into your pgm.

I haven't done this in a while, but you can define the field as unsigned, then move it to itself. That strips the sign.
Code:

01  rec1.
     .
     .
     .
    05  var1  pic 9(004).
     .
     .

move var1 to var1
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
No new posts Convert HEX to Numeric DB2 3
Search our Forums:

Back to Top