MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Putting 6 numbers in a char(2) field

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
whizkid79
Beginner


Joined: 29 Sep 2004
Posts: 53
Topics: 14

PostPosted: Wed Sep 29, 2004 2:38 pm    Post subject: Putting 6 numbers in a char(2) field Reply with quote

Hi,

Is there anyway to store 6 numbers in a char(2) field by converting the number to hex or binary?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Wed Sep 29, 2004 4:52 pm    Post subject: Reply with quote

whizkid79,

What is the max and min value you want to store in the 6 byte field?

max = +999,999
min = -999,999

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Sep 29, 2004 5:03 pm    Post subject: Reply with quote

You're going to need quite a shoehorn to get a 6 digit value into a 2-byte binary field since the maximum positive 2-byte binary value is X'FFFF' = 65535 = 5 digits.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
whizkid79
Beginner


Joined: 29 Sep 2004
Posts: 53
Topics: 14

PostPosted: Wed Sep 29, 2004 6:16 pm    Post subject: Reply with quote

yes. only positive numbers.
max = +999,999

I know it is impossible. Just checking whether there is a way or not.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Wed Sep 29, 2004 7:04 pm    Post subject: Reply with quote

whizkid79,

As far as I know I don't think it is possible to store that number in 2 bytes.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mike Chantrey
Intermediate


Joined: 10 Sep 2003
Posts: 234
Topics: 1
Location: Wansford

PostPosted: Mon Oct 04, 2004 7:59 am    Post subject: Reply with quote

It depends...
It's not really possible in the general case for 'random' data which is distributed across the full range of values, since you can't have more than 65536 *different* values in 2 bytes, but that doesn't necessarily mean you can't store 999999 as a coded value in two bytes. Suppose for example that your data contains less than 65536 distinct values, then you can have an encoding scheme where each of these distinct values was encoded as a number from 0-65535 via a translation table. This table is a one off fixed overhead, and each data value can then be stored as two bytes.
Real data often has 'holes' - values that never occur - so you might be able to use this feature as above.

Or suppose that the data has some sort of pattern to it (non-random). The less randomness the data contains the more it can be compressed - to take it to extremes, a file containing 200 letter 'A's can be easily compressed to x'240'+'A' (i.e. to 1% of its length). So if your data as a whole was very non-random you could get something like PKZIP to compress it to an *average* of less than 2 bytes per 6-digit number. But this is for an entire file, not a specific field.
Back to top
View user's profile Send private message
Mike Chantrey
Intermediate


Joined: 10 Sep 2003
Posts: 234
Topics: 1
Location: Wansford

PostPosted: Mon Oct 04, 2004 8:01 am    Post subject: Reply with quote

Correction: x'240' above should read x'C8' = decimal 200
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group