mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Deprecate uXX and iXX bit suffixes.
Add experimental LL / ULL suffixes for int128 and uint128 literals.
This commit is contained in:
@@ -9,8 +9,8 @@ fn void check(uint128 a, uint128 b)
|
||||
|
||||
fn void test_big() @test
|
||||
{
|
||||
uint128 a = 12345678901234567890012u128;
|
||||
uint128 b = 1234567890123456789001u128;
|
||||
uint128 a = 12345678901234567890012ULL;
|
||||
uint128 b = 1234567890123456789001ULL;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
for (int j = 0; j < 10; j++)
|
||||
|
||||
@@ -49,7 +49,7 @@ fn void test_expect()
|
||||
int a = 2;
|
||||
int b = 43;
|
||||
int c = @expect(a, 2, 0.5);
|
||||
int d = @expect(b, 2u8);
|
||||
int d = @expect(b, 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ fn void test_plus()
|
||||
BigInt b = bigint::from_int(234);
|
||||
assert(a.add(b).equals(bigint::from_int(234 + 123)));
|
||||
|
||||
a = bigint::from_int(12323400012311213314141414i128);
|
||||
b = bigint::from_int(23400012311213314141414i128);
|
||||
assert(a.add(b).equals(bigint::from_int(12323400012311213314141414i128 + 23400012311213314141414i128)));
|
||||
a = bigint::from_int(12323400012311213314141414LL);
|
||||
b = bigint::from_int(23400012311213314141414LL);
|
||||
assert(a.add(b).equals(bigint::from_int(12323400012311213314141414LL + 23400012311213314141414LL)));
|
||||
}
|
||||
|
||||
fn void test_mult()
|
||||
@@ -45,9 +45,9 @@ fn void test_mult()
|
||||
BigInt b = bigint::from_int(234);
|
||||
assert(a.mult(b).equals(bigint::from_int(234 * 123)));
|
||||
|
||||
a = bigint::from_int(1232311213314141414i128);
|
||||
b = bigint::from_int(234000123112414i128);
|
||||
assert(a.mult(b).equals(bigint::from_int(1232311213314141414i128 * 234000123112414i128)));
|
||||
a = bigint::from_int(1232311213314141414LL);
|
||||
b = bigint::from_int(234000123112414LL);
|
||||
assert(a.mult(b).equals(bigint::from_int(1232311213314141414LL * 234000123112414LL)));
|
||||
}
|
||||
|
||||
fn void test_minus()
|
||||
@@ -56,9 +56,9 @@ fn void test_minus()
|
||||
BigInt b = bigint::from_int(234);
|
||||
assert(a.sub(b).equals(bigint::from_int(123 - 234)));
|
||||
|
||||
a = bigint::from_int(12323400012311213314141414i128);
|
||||
b = bigint::from_int(23400012311213314141414i128);
|
||||
assert(a.sub(b).equals(bigint::from_int(12323400012311213314141414i128 - 23400012311213314141414i128)));
|
||||
a = bigint::from_int(12323400012311213314141414LL);
|
||||
b = bigint::from_int(23400012311213314141414LL);
|
||||
assert(a.sub(b).equals(bigint::from_int(12323400012311213314141414LL - 23400012311213314141414LL)));
|
||||
}
|
||||
|
||||
fn void test_init_string_radix()
|
||||
|
||||
@@ -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});
|
||||
|
||||
Reference in New Issue
Block a user