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

  • Home
  • SEARCH
  • 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 41975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:15:56+00:00 2026-05-10T15:15:56+00:00

If you have binary strings (literally String objects that contain only 1’s and 0’s),

  • 0

If you have binary strings (literally String objects that contain only 1’s and 0’s), how would you output them as bits into a file?

This is for a text compressor I was working on; it’s still bugging me, and it’d be nice to finally get it working. Thanks!

  • 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. 2026-05-10T15:15:56+00:00Added an answer on May 10, 2026 at 3:15 pm

    Easiest is to simply take 8 consecutive characters, turn them into a byte and output that byte. Pad with zeros at the end if you can recognize the end-of-stream, or add a header with length (in bits) at the beginning of the file.

    The inner loop would look something like:

     byte[] buffer = new byte[ ( string.length + 7 ) / 8 ]; for ( int i = 0; i < buffer.length; ++i ) {    byte current = 0;    for ( int j = 7; j >= 0; --j )        if ( string[ i * 8 + j ] == '1' )            current |= 1 << j;    output( current ); } 

    You'll need to make some adjustments, but that's the general idea.

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

Sidebar

Ask A Question

Stats

  • Questions 204k
  • Answers 204k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This should do what you need it to. It will… May 12, 2026 at 8:50 pm
  • Editorial Team
    Editorial Team added an answer Runtime implications in terms of correctness? No - this should… May 12, 2026 at 8:50 pm
  • Editorial Team
    Editorial Team added an answer You can nest your UpdatePanels so that your Label has… May 12, 2026 at 8:50 pm

Related Questions

If you have binary strings (literally String objects that contain only 1's and 0's),
I have some data in string format that represents binary data (e.g. '0x0002'). Is
Encoding issues are among the one topic that have bitten me most often during
Lets say you have various objects of arbitrary type that you would like to
I need to find a str[possibly n]cmp out of a hostile binary file. The

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.