-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/unsigned int #1091
base: master
Are you sure you want to change the base?
Feature/unsigned int #1091
Conversation
e625cdf
to
e58e323
Compare
thanks for the PR, the build currently fails on linting |
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
Adds support for
UInt32
andUInt64
. For the 64 bit versions, the 8 bytes are stored as aBLOB
in big endian format. UInt32 are stored in a normalINTEGER
column