5 个版本
| 0.1.4 | 2023 年 7 月 3 日 |
|---|---|
| 0.1.3 | 2023 年 4 月 18 日 |
| 0.1.2 | 2023 年 2 月 18 日 |
| 0.1.1 | 2023 年 2 月 7 日 |
| 0.1.0 | 2023 年 2 月 7 日 |
#31 in 无标准库
50,509 每月下载量
用于 481 个 crates(4 个直接使用)
165KB
3K SLoC
Rust 常量上下文中的浮点数
浮点代码来自 compiler_builtins = "0.1.94" 和 libm = "0.2.6",并已重写以用于常量上下文。
对所有操作进行模糊测试,以相关参考代码进行测试,以确保移植的正确性,但如果存在任何不一致的行为,请提出问题。
导出的软浮点类型
SoftF32SoftF64
功能
no_std- 默认启用const_trait_impl- 用于常量操作符实现const_mut_refs- 用于具有赋值实现的常量操作符
在 stable 上
const fn const_f32_add(a: f32, b: f32) -> f32 {
SoftF32(a).add(SoftF32(b)).to_f32()
}
在 nightly 上使用 const_trait_impl
const fn const_f32_add(a: f32, b: f32) -> f32 {
(SoftF32(a) + SoftF32(b)).to_f32()
}
在 nightly 上使用 const_mut_refs
const fn const_f32_add(a: f32, b: f32) -> f32 {
let mut x = SoftF32(a);
x += SoftF32(b);
x.to_f32()
}
实现 const 函数
from_(f32/f64)to_(f32/f64)from_bitsto_bitsaddsubmuldivcmpnegsqrtpowicopysigntruncroundfloorsincos