This commit is contained in:
chriseth 2021-08-17 16:54:13 +02:00
parent 2beb87eb02
commit a6f739f38d
5 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,22 @@
contract C {
function test() public pure returns (bool) {
fixed64x4 x = fixed64x4(-1.12346789);
fixed64x4 y = -1.1235;
ufixed32x4 z = 1;
require(x == x);
require(x > y);
require(x >= y);
require(x != y);
require(y <= x);
require(!(x < y));
require(y < z);
require(x < z);
require(z >= x);
require(z == z);
return true;
}
}
// ====
// compileViaYul: also
// ----
// test() -> true

View File

@ -0,0 +1,12 @@
contract C {
function test() public pure returns (bool) {
require(1/2 == 1/2);
require(fixed128x2(1/2 + 0.0000001) == 1/2);
require(fixed128x2(1/3) < 1/2);
return true;
}
}
// ====
// compileViaYul: also
// ----
// test() -> true

View File

@ -0,0 +1,10 @@
contract C {
function test() public pure returns (fixed64x3, fixed128x4, ufixed64x4) {
fixed64x4 x = fixed64x4(-1.12346789);
return (fixed64x3(x), fixed128x4(x), ufixed64x4(x));
}
}
// ====
// compileViaYul: also
// ----
// test() -> -1.123, -1.1234, 1844674407370954.0382

View File

@ -0,0 +1,19 @@
contract C {
function f() public pure returns (bytes memory) {
return abi.encodePacked(
1.23,
fixed64x4(-1.234)
);
}
function g() public pure returns (bytes memory) {
return abi.encode(
1.23,
fixed64x4(-1.234)
);
}
}
// ====
// compileViaYul: also
// ----
// f() ->
// g() ->

View File

@ -0,0 +1,13 @@
contract C {
fixed64x4 public a = -2.123;
fixed64x4 public immutable b = -2.456;
mapping(uint => fixed64x4) public m;
constructor() { m[3] = 1.123; }
}
// ====
// compileViaYul: also
// ----
// a() -> -2.1230
// b() -> -2.4560
// m(uint256): 2 -> 0.0000
// m(uint256): 3 -> 1.1230