Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Encode and decode binary-coded decimals

by jmcnamara (Monsignor)
on Oct 08, 2002 at 17:44 UTC ( #203703=note: print w/ replies, xml ) Need Help??


in reply to Re: Encode and decode binary-coded decimals
in thread Encode and decode binary-coded decimals


In the first case you need to use 0396 instead of 396. That's what the comment about "zero padding" refers to.

$ perl -le 'print join " ", map {ord pack "H2", $_} shift =~ /../g +' 0396 3 150

I'd expect to get: 0011 1001 011

That is at odds with my expectation.:-) Nevertheless, it isn't too difficult to change these routines to support other ascii, hex or binary representations.

--
John.


Comment on Re: Re: Encode and decode binary-coded decimals
Download Code
Re: Re: Re: Encode and decode binary-coded decimals
by jryan (Vicar) on Oct 08, 2002 at 20:23 UTC

    My definition of BCD is similar to this, but maybe you are referring to something different? :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://203703]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2015-07-06 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (71 votes), past polls