dart-sdk/tests/corelib/very_big_integer_test.dart
Ryan Macnak bc3aa70e20 [vm, compiler] Fix size of sign-extension in x64c BigInt intrinsics.
TEST=ci
Change-Id: I99aa9875705823c22b5474bb1d66c7bc1aaac9fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202309
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-06-03 22:47:56 +00:00

18 lines
662 B
Dart

// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
main() {
// x and y have lengths in 32-bit digits that overflow 16 bits.
var x = new BigInt.from(13) << (65000 * 32);
var y = new BigInt.from(42) << (65000 * 32);
print(x.bitLength);
Expect.equals(x, (x + y) - y);
Expect.equals(x, -((-x + y) - y));
Expect.equals(x, (x << 2) >> 2);
Expect.equals(x, (x >> 3) << 3);
Expect.equals(0, (x ^ x).toInt());
Expect.equals(0, (y ^ y).toInt());
}