Your terminology is very confusing, but it sounds to me like you want the numerical value 6416 aka 10010 from the string "64". For that, you can use hex.

$ perl -E'say 0x64 == hex("64") ?"yes":"no"' yes

In case I misunderstood, here are some other related conversions:

numerical value 6416 from string "64"hex("64")
numerical value 6416 from string "100""100"
packed byte 6416 from numerical value 6416chr(0x64)
packed byte 6416 from string "64"chr(hex("64"))
packed byte 6416 from string "100"chr("100")
string "64" from numerical value 6416sprintf("%X", 0x64)

pack 'C' would work in lieu of chr.

Update: I just noticed your followup. It seems that you want the packed byte 6416 (aka "d" in ASCII), but you didn't specify from what.

$ perl -E'say "\x64" eq chr(hex("64")) ?"yes":"no"' yes $ perl -E'say "\x64" eq chr(0x64) ?"yes":"no"' yes

That could also be written

$ perl -E'say "\x64" eq pack("C", hex("64")) ?"yes":"no"' yes $ perl -E'say "\x64" eq pack("C", 0x64) ?"yes":"no"' yes

In reply to Re: Dec to Hex (NON-ASCII mode ) by ikegami
in thread Dec to Hex (NON-ASCII mode ) by MathewM

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.