`pow`: Round negative to zero.
- Linguagem predominante
- Rust
- Estrelas
- 225
- Forks
- 70
- Merge médio
- 16h 54min
- PRs com merge (30d)
- 8
Descrição
*On 2022-05-31 @recmo wrote in [`c1a0c34`](https://github.com/recmo/uint/commit/c1a0c34df8ab6d3411ad79c27b72ad812eff78e4) “Merge pull request #97 from recmo/isqrt”:*
Round negative to zero.
Self::BITS ~< 2^52 and so fits f64.
```rust
#[must_use]
pub fn approx_pow2(exp: f64) -> Option {
const LN2_1P5: f64 = 0.584_962_500_721_156_2_f64;
const EXP2_63: f64 = 9_223_372_036_854_775_808_f64;
// FEATURE: Round negative to zero.
#[allow(clippy::cast_precision_loss)] // Self::BITS ~< 2^52 and so fits f64.
if exp < LN2_1P5 {
if exp < -1.0 {
return Some(Self::ZERO);
}
return Self::try_from(1).ok();
```
*From [`src/pow.rs:101`](https://github.com/recmo/uint/blob/c1a0c34df8ab6d3411ad79c27b72ad812eff78e4/src/pow.rs#L101)*
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Avaliação
Esta issue ainda não foi avaliada.