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

Conversion from a varchar holding hexadecimal to decimal


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Mon Nov 10, 2008 9:10 pm
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
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

Moderator Emeritus


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

PostPosted: Tue Nov 11, 2008 11:25 am
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
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Tue Nov 11, 2008 9:09 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
No new posts file manager is doing string conversion IBM Tools 3
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
Search our Forums:

Back to Top