Deprecate uXX and iXX bit suffixes.

Add experimental LL / ULL suffixes for int128 and uint128 literals.
This commit is contained in:
Christoffer Lerno
2025-05-13 23:48:59 +02:00
parent c528f53d58
commit abe4727c3a
25 changed files with 126 additions and 68 deletions

View File

@@ -49,7 +49,7 @@ fn void test_abs() @test
test::eq(math::abs(-2), 2);
test::eq(math::abs(2), 2);
test::eq(math::abs((int[<2>]){ -1, 2 }), (int[<2>]) { 1, 2 });
test::eq(math::abs((int128)-1), (int128)1);
test::eq(math::abs(-1LL), 1LL);
test::eq_approx(math::abs((float[<2>]) { 1, -3 }).x, 1.0, 6);
test::eq_approx(math::abs((float[<2>]) { 1, -3 }).y, 3.0, 6);
@@ -623,17 +623,17 @@ fn void test_muldiv()
assert(e.muldiv(40000, 10000) == 4_000_000);
uint f = 3_000_000_000u;
assert(f.muldiv(110, 100) == 3_300_000_000u);
long g = 1_000_000_000_000i64;
assert(g.muldiv(2_000_000_000_000i64, 1_000_000_000i64) == 2_000_000_000_000_000i64);
ulong h = 1_000_000_000_000u64;
assert(h.muldiv(2_000_000_000_000u64, 1_000_000_000u64) == 2_000_000_000_000_000u64);
long g = 1_000_000_000_000;
assert(g.muldiv(2_000_000_000_000L, 1_000_000_000L) == 2_000_000_000_000_000L);
ulong h = 1_000_000_000_000U;
assert(h.muldiv(2_000_000_000_000UL, 1_000_000_000UL) == 2_000_000_000_000_000UL);
char[<4>] i = {20, 30, 40, 50};
assert(i.muldiv(12,10) == (char[<4>]) {24, 36, 48, 60});
assert(i.muldiv((char[<4>]){11, 12, 13, 14}, (char[<4>]){10,10,10,10}) == (char[<4>]){22, 36, 52, 70});
long[<4>] j = {1_000_000_000_000i64, 2_000_000_000_000i64, 3_000_000_000_000i64, 4_000_000_000_000i64};
assert(j.muldiv(2_000_000_000_000i64, 1_000_000_000i64) == (long[<4>]){2_000_000_000_000_000i64, 4_000_000_000_000_000i64, 6_000_000_000_000_000i64, 8_000_000_000_000_000i64});
long[<4>] j = {1_000_000_000_000, 2_000_000_000_000, 3_000_000_000_000, 4_000_000_000_000};
assert(j.muldiv(2_000_000_000_000L, 1_000_000_000L) == (long[<4>]){2_000_000_000_000_000, 4_000_000_000_000_000, 6_000_000_000_000_000, 8_000_000_000_000_000});
ichar[<4>] k = {20, 30, 40, 50};
assert(k.muldiv(20,-10) == (ichar[<4>]){-40,-60,-80,-100});