Skip to content

Instantly share code, notes, and snippets.

@ikskuh
Created January 10, 2020 15:13
Show Gist options
  • Save ikskuh/0e49fe71698c10f61d7d1e76b373d380 to your computer and use it in GitHub Desktop.
Save ikskuh/0e49fe71698c10f61d7d1e76b373d380 to your computer and use it in GitHub Desktop.
const fixed_22_10 = arithmetic(i32) {
const Self = @This();
fn add(lhs: Self, rhs: Self) Self {
return @as(Self, @value(lhs) + @value(rhs));
}
fn mul(lhs: Self, rhs: Self) Self {
return @as(Self, (@as(i64, @value(lhs)) * @as(i64, @value(rhs))) / 1024);
}
// ...
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment