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: 2 additions & 2 deletions pkgs/fixnum/lib/src/int64_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ class Int64 implements IntX {
throw ArgumentError('toStringRadixUnsigned radix must be >= 2 and <= 36'
' (found $radix)');
}
if (value == 0) {
return '0';
if (value >= 0) {
return value.toRadixString(radix);
}
// Split value into two 32-bit unsigned digits (v1, v0).
final v1 = value >>> 32;
Expand Down
19 changes: 18 additions & 1 deletion pkgs/fixnum/test/int64_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,24 @@ void main() {
});

test('toStringUnsigned', () {
List<Int64> values = [];
expect(Int64.MAX_VALUE.toStringUnsigned(), '9223372036854775807');
expect(Int32.MAX_VALUE.toInt64().toStringUnsigned(), '2147483647');
expect(Int64(2).toStringUnsigned(), '2');
expect(Int64(1).toStringUnsigned(), '1');
expect(Int64(0).toStringUnsigned(), '0');
expect(Int64(-1).toStringUnsigned(), '18446744073709551615');
expect(Int64(-2).toStringUnsigned(), '18446744073709551614');
expect(
Int32.MIN_VALUE.toInt64().toStringUnsigned(), '18446744071562067968');
expect(Int64.MIN_VALUE.toStringUnsigned(), '9223372036854775808');

List<Int64> values = [
Int64.MAX_VALUE,
Int64(1),
Int64(0),
Int64(-1),
Int64.MIN_VALUE,
];
for (int high = 0; high < 16; high++) {
for (int low = -2; low <= 2; low++) {
values.add((Int64(high) << (64 - 4)) + Int64(low));
Expand Down
Loading