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 7161493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:34:34+00:00 2026-05-28T13:34:34+00:00

I am still struggling with bitwise operators using Ruby. Getting a value 11100 (28

  • 0

I am still struggling with bitwise operators using Ruby.

Getting a value 11100 (28 in base 10) (from a bitstream), I’d like to see it as -4, that is signed integer on 5 bits.

How would you proceed ?

I know the generic pseudo-algorithm says :
-X = “/X +1” ie : to get the opposite of X, first flip bits of X, then increment by 1. But here I am stucked !

  • 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-28T13:34:34+00:00Added an answer on May 28, 2026 at 1:34 pm

    Iff the left most bit is a 1 then it is negative number.

    So take your 28 and subtract 32 (2^5) to get -4.

    But -2 would be 11110

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

Sidebar

Related Questions

I come from a C background, so I admit that I'm still struggling with
Really like objectify, although still struggling with what is the best way to structure
EDIT 4 July: Still struggling with this issue. I'm sure all that's required is
I am still struggling to find a good naming convention for assets like images,
Following on from this question , I am still struggling with the Twitter Bootstrap.
I'm still struggling with a JTable that should be automatically updated. The situation is
I am still struggling to understand the difference between *p, &p, and p. From
Still struggling to understand what best practices are with respect to macros. I'm attempting
Still new to Objective C, and I'm having some trouble that I just can't
Still struggling with R, especially with error handling: If I use: result <- try(sqlSave(ch,df,tablename=tblTest))

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.