Matthias Krüger
cea6ba7a06
Rollup merge of #140172 - bjoernager:const-float-algebraic, r=RalfJung
Make algebraic functions into `const fn` items.
Tracking issue: #136469
This PR makes the algebraic intrinsics and the unstable, algebraic functions of `f16`, `f32`, `f64`, and `f128` into `const fn` items:
```rust
impl f16 {
pub const fn algebraic_add(self, rhs: f16) -> f16;
pub const fn algebraic_sub(self, rhs: f16) -> f16;
pub const fn algebraic_mul(self, rhs: f16) -> f16;
pub const fn algebraic_div(self, rhs: f16) -> f16;
pub const fn algebraic_rem(self, rhs: f16) -> f16;
}
impl f32 {
pub const fn algebraic_add(self, rhs: f32) -> f32;
pub const fn algebraic_sub(self, rhs: f32) -> f32;
pub const fn algebraic_mul(self, rhs: f32) -> f32;
pub const fn algebraic_div(self, rhs: f32) -> f32;
pub const fn algebraic_rem(self, rhs: f32) -> f32;
}
impl f64 {
pub const fn algebraic_add(self, rhs: f64) -> f64;
pub const fn algebraic_sub(self, rhs: f64) -> f64;
pub const fn algebraic_mul(self, rhs: f64) -> f64;
pub const fn algebraic_div(self, rhs: f64) -> f64;
pub const fn algebraic_rem(self, rhs: f64) -> f64;
}
impl f128 {
pub const fn algebraic_add(self, rhs: f128) -> f128;
pub const fn algebraic_sub(self, rhs: f128) -> f128;
pub const fn algebraic_mul(self, rhs: f128) -> f128;
pub const fn algebraic_div(self, rhs: f128) -> f128;
pub const fn algebraic_rem(self, rhs: f128) -> f128;
}
// core::intrinsics
pub const fn fadd_algebraic<T: Copy>(a: T, b: T) -> T;
pub const fn fsub_algebraic<T: Copy>(a: T, b: T) -> T;
pub const fn fmul_algebraic<T: Copy>(a: T, b: T) -> T;
pub const fn fdiv_algebraic<T: Copy>(a: T, b: T) -> T;
pub const fn frem_algebraic<T: Copy>(a: T, b: T) -> T;
```
This PR does not preserve the initial behaviour of these functions yielding non-deterministic output under Miri; it is most likely desired to reimplement this behaviour at some point.
2025-04-24 17:19:46 +02:00
..
2025-04-13 01:11:04 -04:00
2025-04-22 01:15:06 +00:00
2025-04-23 16:37:39 -04:00
2025-04-18 05:16:29 +02:00
2025-04-24 08:13:01 +02:00
2025-04-20 11:15:46 +02:00
2025-04-22 01:15:06 +00:00
2025-04-23 00:43:07 +00:00
2025-04-22 15:24:07 +00:00
2025-04-24 13:14:36 +07:00
2025-04-24 13:14:36 +07:00
2025-04-24 17:19:44 +02:00
2025-04-20 13:02:48 +00:00
2025-04-24 17:19:46 +02:00
2025-04-14 01:38:18 +02:00
2025-04-14 03:56:55 +00:00
2025-04-20 11:18:38 +02:00
2025-04-09 12:29:59 +01:00
2025-04-16 21:38:59 -04:00
2025-04-22 01:15:06 +00:00
2025-04-21 18:53:15 +00:00
2025-04-11 15:07:08 +02:00
2025-04-23 16:37:39 -04:00
2025-04-22 11:02:37 +00:00
2025-04-15 10:41:10 +10:00
2025-04-24 08:13:00 +02:00
2025-04-17 09:50:52 +10:00
2025-04-15 10:44:28 -04:00
2025-04-12 11:53:07 +00:00
2025-04-23 15:09:25 +00:00
2025-04-19 19:30:46 +00:00
2025-04-24 17:19:43 +02:00
2025-04-24 13:14:36 +07:00
2025-04-12 01:36:44 -04:00
2025-04-23 11:14:27 +10:00
2025-04-19 15:09:35 +00:00
2025-04-23 21:35:15 +00:00
2025-04-24 08:13:00 +02:00
2025-04-22 10:08:05 +10:00
2025-04-24 17:19:42 +02:00
2025-04-24 08:12:58 +02:00
2025-04-24 11:40:46 +02:00
2025-04-24 11:40:47 +02:00
2025-04-20 11:18:38 +02:00
2025-04-16 21:38:59 -04:00
2025-04-14 03:56:55 +00:00
2025-04-17 00:14:24 +02:00
2025-04-20 11:15:46 +02:00
2025-04-15 15:47:27 +10:00
2025-04-10 18:52:03 +02:00
2025-04-24 17:19:44 +02:00
2025-04-24 08:13:01 +02:00
2025-04-20 11:15:46 +02:00
2025-04-15 21:16:05 +02:00
2025-04-24 17:19:44 +02:00
2025-04-24 12:06:16 +00:00
2025-04-09 10:42:26 +00:00
2025-04-23 11:45:00 -07:00
2025-04-24 11:40:35 +02:00
2025-04-23 15:09:25 +00:00
2025-04-15 18:30:35 +00:00
2025-04-05 18:23:07 +08:00