Closed dangfan closed 6 months ago
After discussing with @Harry-Chen , I've changed the order to detect the type of an object. It works because "On the web, the underlying int type is like a subtype of double: it’s a double-precision value without a fractional part. In fact, a type check on the web of the form x is int returns true if x is a number (double) with a zero-valued fractional part."
Also, using toSigned(32)
works on web.
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
cd21a16
) 70.97% compared to head (2e6f64b
) 70.97%.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Great addition thanks. Package re published at version 6.2.0.
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