Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Conversion from a varchar holding hexadecimal to decimal

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
souji

New User


Joined: 28 Aug 2008
Posts: 9
Location: Bangalore

PostPosted: Mon Nov 10, 2008 5:42 pm    Post subject: Conversion from a varchar holding hexadecimal to decimal
Reply with quote

Hi,

I have encountered the following situation and need your help regarding the following.

I have a varchar variable which at some position is holding '.....&..' If I retrieve this value in a char variable I get '.....&..'. But actually this is the hexadecimal for 500.11. My requirement is to pull this as a decimal. A decimal variable declared as fixed decimal(15,2) should hold 500.11.

can this be done though the built in functions or/and the implicit assignments.

Please help !
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Nov 10, 2008 9:10 pm    Post subject:
Reply with quote

Hello Soujanya and welcome to the forum,

First - are you working with pl/i or assembler (or)?

Next - please post the "hex" content for the '.....&..' value.

Quote:
A decimal variable declared as fixed decimal(15,2) should hold 500.11.
A field of 15,2 should hold a value much greater than 500.11. . .

If you post the bit of problem code (not the entire program) someone shouold be able to offer a suggestion.
Back to top
View user's profile Send private message
souji

New User


Joined: 28 Aug 2008
Posts: 9
Location: Bangalore

PostPosted: Tue Nov 11, 2008 11:16 am    Post subject: Conversion from a varchar holding hexadecimal to decimal
Reply with quote

Hi Dick...

I am working on PL/I..

the hex content for the value is
.....&..
00000501
0000001C

Thanks & Regards,
Soujanya[/img]
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Nov 11, 2008 11:25 am    Post subject:
Reply with quote

Hello,

The value you posted is a valid packed decimal number with a value of 50011. The "C" indicates the number is positive.

Are you familiar with the packed-decimal data format?
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Tue Nov 11, 2008 12:06 pm    Post subject:
Reply with quote

Souji,
You can redefine the same char field with a dec(15,2).
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 994
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Tue Nov 11, 2008 9:09 pm    Post subject:
Reply with quote

Quote:
You can redefine the same char field with a dec(15,2).


In the case described by the O/P, the varchar has length 8. A dec fixed(15,n) field could be overlaid on this. However, if the varchar is a different length, DEC FIXED(15,n) will be incorrect. Multiple overlays of dec fixed fields could be used, selecting which overlay to use on the basis of the length of the varchar?

Garry.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Conversion of a VB file to FB. isssal DFSORT/ICETOOL 1 Mon Oct 31, 2016 10:23 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us