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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:34:08+00:00 2026-06-10T19:34:08+00:00

You can read a binary file byte by byte using f:read(size) in which size

  • 0

You can read a binary file byte by byte using f:read(size) in which size represent the number of byte but how can I read it bit by bit ? (1/8 of byte or octet if you want)

It’s ok for most of the data Int8(1),Uint16(2),Uint32(4),Int*(4)
But for BOOL(0.125 ?).

Thanks for your help !

EDIT : My problem is obviously not to read the file bit by bit but to manage to extract all the data, including some boolean value (without creating a “shift” of 1 bit).

  • 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-06-10T19:34:09+00:00Added an answer on June 10, 2026 at 7:34 pm

    You can’t. A byte is the smallest unit that can be read from a file. You could write code that wraps the bytewise access to make it look bitwise.

    The appropriate way to read a boolean value from a file depends on how it was written. Unless you go to the exact same sort of trouble to write boolean values bit by bit then there’s no need to read them that way.

    The Lua file API only deals in numbers and strings. To write a boolean value you’d convert it to one of these types. To read it you would read one of these types and the perform the inverse of the conversion you used for writing. For example you might convert true to 1 and false to 0, and then write and read numbers. Or you might try to pack several boolean values into one number. In any case, you don’t need to read or write the file bit by bit to read and write boolean data.

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

Sidebar

Related Questions

If I read and wrote a binary file using StreamReader and StreamWriter, can the
i want to read\write a binary file which has the following structure: The file
I have binary data in a file that I can read into a byte
I have a 16mb binary file and I want to read bytes without using
I can read unmanaged memory in C# using UnmanagedMemoryStream, but how can I do
I'm trying to read a binary file (which represents a matrix in Matlab) in
Using C#, I need to read a packed binary file created using FORTRAN. The
I have a binary file which I'm reading where some 2 byte values are
I'm using python to read a text file with the segment below (can't post
I use this routine to do a binary read from file to memory, which

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.