Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@adamwulf
Copy link
Contributor

Adds support for UInt32 and UInt64. For the 64 bit versions, the 8 bytes are stored as a BLOB in big endian format. UInt32 are stored in a normal INTEGER column

@adamwulf adamwulf force-pushed the feature/unsigned-int branch from e625cdf to e58e323 Compare October 20, 2021 23:08
@jberkel
Copy link
Collaborator

jberkel commented Oct 21, 2021

thanks for the PR, the build currently fails on linting

@adamwulf
Copy link
Contributor Author

Just pushed up a commit to fix the linting error

public var datatypeValue: Blob {
var bytes: [UInt8] = []
withUnsafeBytes(of: self) { pointer in
// little endian by default on iOS/macOS, so reverse to get bigEndian
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about Linux? Will this work everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah you're right, this would likely fail on non-macOS. i'll look for the right way to get defined bit order regardless of system.

Copy link
Collaborator

Choose a reason for hiding this comment

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

the simplest way here would be

withUnsafeBytes(of: bigEndian) { pointer in
   bytes.append(contentsOf: pointer)
}

however, why is it stored as big endian by default? given that it implies a conversion in most cases.

let lBytes: [UInt8] = lhs.bytes.reversed()
let rBytes: [UInt8] = rhs.bytes.reversed()

for byteIndex in stride(from: max(lhs.bytes.count, rhs.bytes.count) - 1, to: 0, by: -1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

wouldn't it be easier to change the iteration from 0 to bytes.count to avoid having to do reversed in the first place?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.