Need some python help (or maybe C )

Kurt Wall kwall at kurtwerks.com
Sun Dec 14 10:43:04 PST 2008


On Sat, Dec 13, 2008 at 09:18:39PM -0800, Kurt Wall wrote:
> On Sat, Dec 13, 2008 at 11:40:58AM -0600, Ben Duncan wrote:
> >
> > I have a hex value as x'000123456D". It is a COMP-3 (Binary coded decimal)
> > for a cobol program. That says to me and is in actuality the number 123456-,
> > The LAST nibble D is negative and F or C would be postive.
> >
> > I need to get this to a "integer" or a string.
> 
> $ perl -e 'print unpack("I", 0x000123456D), "\n";'
> 942684465

Ya know, that's completely wrong. Try:

$ perl -e 'print sprintf("%d\n", 0x000123456), "\n";'
1193046

Kurt
-- 
Juall's Law on Nice Guys:
	Nice guys don't always finish last; sometimes they don't finish.
	Sometimes they don't even get a chance to start!



More information about the Linux-users mailing list