negative value in natural

Software AG's platform-independent programming language with full support for open-source and Internet applications
mainframe1
Posts: 35
Joined: Wed Oct 08, 2008 11:39 am
Skillset: cobol, dn2, jcl, adabas, roscoe
Referer: FRIEND

negative value in natural

Postby mainframe1 » Sun Dec 13, 2015 6:20 pm

Hi,
Pls let me know how u handle negative values in natural for calculations

NicC
Global moderator
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
Referer: Google
Location: Pushing up the daisies (almost)

Re: negative value in natural

Postby NicC » Sun Dec 13, 2015 6:40 pm

You should have the manuals available to you so refer to them. Also, look at other programs and see how they deal with them.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

mainframe1
Posts: 35
Joined: Wed Oct 08, 2008 11:39 am
Skillset: cobol, dn2, jcl, adabas, roscoe
Referer: FRIEND

Re: negative value in natural

Postby mainframe1 » Sun Dec 13, 2015 7:02 pm

i had look at the manuals

to elaborate
can i move -234.5678 to N(999.9999).
pls explain

User avatar
RGZbrog
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Skillset: Natural, Adabas, Predict, Natural Security, Construct, EntireX, SPoD, NaturalONE
Referer: SAG Developer Forum
Location: California, USA
Contact:

Re: negative value in natural

Postby RGZbrog » Mon Dec 14, 2015 2:24 pm

Natural processes external decimal (format N) values just like any other mainframe language would. That is, the right-most byte contains the sign in the left nibble. Here's some code to demonstrate.

Code: Select all

DEFINE DATA LOCAL
1 #N (N3.4)
END-DEFINE
MOVE -234.5678 TO #N
WRITE '=' #N #N (EM=HHHHHHH)
END
And here's the output.

Code: Select all

Page     1                                                   12/14/15  00:47:05
 
#N: -234.5678 F2F3F4F5F6F7D8
Notice that the field definition is N3.4; 3 digits before the implied decimal point, 4 digits after.

mainframe1
Posts: 35
Joined: Wed Oct 08, 2008 11:39 am
Skillset: cobol, dn2, jcl, adabas, roscoe
Referer: FRIEND

Re: negative value in natural

Postby mainframe1 » Mon Dec 14, 2015 5:28 pm

thanks RGZgrog :)


  • Similar Topics
    Replies
    Views
    Last post