Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6164539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:00:38+00:00 2026-05-23T22:00:38+00:00

I am using ruby 1.9.2 and this is what I found. > [‘A’].pack(‘H’) =>

  • 0

I am using ruby 1.9.2 and this is what I found.

> ['A'].pack('H')
=> "\xA0" 

Since H takes high nibble first and since the input A is only one nibble the additional nibble should be padded at the front. Which means the above code should be same as

> ['0A'].pack('H')

But it seems I am missing something. Anyone cares to explain.

Since the answer of the first case is \xA0 it is clear that the zero is being padded to the right. However when we are dealing with high nibble first then A should be same as 0A .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:00:40+00:00Added an answer on May 23, 2026 at 10:00 pm

    If you pack half a byte, one nibble, that’s what you’ll get. You need to specify how long your input string is in nibbles:

    'X'.unpack('h')
    # => ["8"]
    'X'.unpack('h2')
    # => ["85"]
    
    'X'.unpack('H')
    # => ["5"]
    'X'.unpack('H2')
    # => ["58"]
    

    To pack is to do the opposite of unpack, so don’t omit the length argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie to ruby this is my first project I am using the FasterCSV Gem
I want to download this picture using Ruby. How do I do that? http://farm1.static.flickr.com/92/218926700_ecedc5fef7_o.jpg
this week I'm having problems logging in LinkedIn using ruby mechanize. My code is
I will make this quick. I'm using Ruby/LDAP to search using my base_dn criteria.
If I run a command like this, using ruby's pty class, how do I
given an xml string like this: <some><nested><xml>value</xml></nested></some> what's the best option (using ruby) to
I have a ruby application that executes ant as a subprocess using backtick. This
using Ruby on Rails 2.3.2, since I already created Scaffold for Story, so instead
I've previously written some selenium tests using ruby/rspec, and found it quite powerful. Now,
I am using Ruby on Rails 3.0.9 and I had this problem: Trouble on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.