Update Bitwise Complement Operator and Type Checks for Web Compatibility #58
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces changes to the handling of the bitwise complement operator and type checks to accommodate differences in behavior between native and web environments. The changes are detailed below:
Modification of Bitwise Complement (~) Operation:
~4
is not equivalent to-5
as it is in native environments. To address this discrepancy, the implementation of the~
operator in_ArgInt
has been updated.kIsWeb
) and, if so, applies-value - 1
instead of the native~value
. This change ensures consistent results across platforms.Type Checking for Integer Objects:
int
anddouble
, the existing type check was inadequate.isWebDouble
has been introduced to accurately determine if an object is a double type representing an integer on the web.CborFloat
inCborValue
has been updated to include a check usingisWebDouble
, ensuring correct type interpretation on the web.Implications for Encoding Float-like Integers and Unaffected Native Behavior:
Affected Files:
lib/src/utils/arg.dart
lib/src/utils/utils.dart
lib/src/value/value.dart