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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:45:20+00:00 2026-05-19T16:45:20+00:00

I tried to read from a file where numbers are stored as 16-bit signed

  • 0

I tried to read from a file where numbers are stored as 16-bit signed integers in big-endian format.

I used unpack to read in the number, but there is no parameter for a 16-bit signed integer in big-endian format, only for an unsigned integer. Here is what I have so far:

number = f.read(2).unpack('s')[0]

Is there a way to interpret the number above as a signed integer or another way to achieve what I want?

  • 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-19T16:45:21+00:00Added an answer on May 19, 2026 at 4:45 pm

    Found a solution that works by reading two 8bit unsigned integers and convert them to a 16bit big-endian integer

    bytes = f.read(2).unpack('CC')  
    elevation = bytes[0] << 8 | bytes[1]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a value I read in from a file and is stored as
I want to read a long number from file then increment it and write
I have a file(both .dat and .txt format) which contains numbers(integers) in rows and
I'm having issues when I try to read a float number from a file.
I have code to read in the version number from a make file. VERSION_ID=map(int,re.match(VERSION_ID\s*=\s*(\S+),open(version.mk).read()).group(1).split(.))
I am trying to read some data from a xml file, numbers are saved
I want to read in a grid of numbers (n*n) from a file and
I tried to implement this example to write and read data from internal storage,
HI all, When I tried to read the record of all peoples from the
I was trying to read the HTML contents from a url. I tried with

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.