Skip to content

Added signed int support to bitstream#290

Merged
jr1221 merged 2 commits into
mainfrom
feature/bitstream-signed
May 25, 2025
Merged

Added signed int support to bitstream#290
jr1221 merged 2 commits into
mainfrom
feature/bitstream-signed

Conversation

@bjackson312006

@bjackson312006 bjackson312006 commented May 19, 2025

Copy link
Copy Markdown
Collaborator

Changes

Added signed int support to bitstream.c using _Generic. bitstream_add() is a macro now, but everything should still work the same. I also removed bitstream_read() since it's not really useful and would probably just be confusing now that bitstream also supports signed ints.

Notes

Not tested yet

Checklist

  • No merge conflicts
  • All checks passing
  • Assign the PR to yourself
  • Request reviewers & ping on Slack

@bjackson312006 bjackson312006 force-pushed the feature/bitstream-signed branch from 124a966 to 41babae Compare May 19, 2025 18:45
@bjackson312006 bjackson312006 force-pushed the feature/bitstream-signed branch from 41babae to 4929163 Compare May 19, 2025 21:04
@bjackson312006 bjackson312006 self-assigned this May 19, 2025
@bjackson312006 bjackson312006 marked this pull request as ready for review May 19, 2025 21:04
@bjackson312006 bjackson312006 requested a review from jr1221 May 19, 2025 21:05

@jr1221 jr1221 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works

result |= (1 << (num_bits - 1 - i));
if (unsigned_value & (1u << (num_bits - 1 - i))) {
bitstream->data[(bitstream->total_bits + i) / 8] |=
(1 << (7 - ((bitstream->total_bits + i) % 8)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this code handle the leftmost signed bit?

@jr1221 jr1221 merged commit c7704a9 into main May 25, 2025
2 checks passed
@jr1221 jr1221 deleted the feature/bitstream-signed branch May 25, 2025 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants