Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dart/packages/fory/lib/src/types/uint16.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ final class Uint16 implements Comparable<Uint16> {

Uint16 operator <<(int shift) => Uint16(value << shift);

Uint16 operator >>(int shift) => Uint16(value >> shift);
Uint16 operator >>(int shift) => Uint16(value >>> shift);

Uint16 operator >>>(int shift) => Uint16(value >>> shift);

bool operator <(Object other) => switch (other) {
int otherValue => value < otherValue,
Expand Down
4 changes: 3 additions & 1 deletion dart/packages/fory/lib/src/types/uint32.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ final class Uint32 implements Comparable<Uint32> {

Uint32 operator <<(int shift) => Uint32(value << shift);

Uint32 operator >>(int shift) => Uint32(value >> shift);
Uint32 operator >>(int shift) => Uint32(value >>> shift);

Uint32 operator >>>(int shift) => Uint32(value >>> shift);

bool operator <(Object other) => switch (other) {
int otherValue => value < otherValue,
Expand Down
4 changes: 3 additions & 1 deletion dart/packages/fory/lib/src/types/uint8.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ final class Uint8 implements Comparable<Uint8> {

Uint8 operator <<(int shift) => Uint8(value << shift);

Uint8 operator >>(int shift) => Uint8(value >> shift);
Uint8 operator >>(int shift) => Uint8(value >>> shift);

Uint8 operator >>>(int shift) => Uint8(value >>> shift);

bool operator <(Object other) => switch (other) {
int otherValue => value < otherValue,
Expand Down
7 changes: 7 additions & 0 deletions dart/packages/fory/test/numeric_wrapper_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,22 @@ void main() {
expect(Uint8(0xff) + 1, equals(Uint8(0)));
expect(Uint8(0) - 1, equals(Uint8(0xff)));
expect(Uint8(0xf0) >> 4, equals(Uint8(0x0f)));
expect(Uint8(0xf0) >>> 4, equals(Uint8(0x0f)));
expect(Uint8(0xff) >> 1, equals(Uint8(0x7f)));
expect(Uint8(0xff) >>> 1, equals(Uint8(0x7f)));
expect(-Uint8(1), equals(Uint8(0xff)));

expect(Uint16(0xffff) + 1, equals(Uint16(0)));
expect(Uint16(0) - 1, equals(Uint16(0xffff)));
expect(Uint16(0xffff) >> 1, equals(Uint16(0x7fff)));
expect(Uint16(0xffff) >>> 1, equals(Uint16(0x7fff)));

expect(Uint32(0xffffffff) + 1, equals(Uint32(0)));
expect(Uint32(0) - 1, equals(Uint32(0xffffffff)));
expect(
Uint32(0xf0f0f0f0) & Uint32(0x0ff00ff0), equals(Uint32(0x00f000f0)));
expect(Uint32(0xffffffff) >> 1, equals(Uint32(0x7fffffff)));
expect(Uint32(0xffffffff) >>> 1, equals(Uint32(0x7fffffff)));

expect(_u64Hex('ffffffffffffffff') + 1, equals(Uint64(0)));
expect(Uint64(0) - 1, equals(_u64Hex('ffffffffffffffff')));
Expand Down
Loading