diff options
| author | Yuval Adam <_@yuv.al> | 2019-03-19 18:12:11 +0200 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2019-03-19 18:17:51 +0200 |
| commit | e2fa36093c58a8d8d97b37a182d45e7d804ab075 (patch) | |
| tree | 387c4b1464182780225b29fc857ab8d1e02b950d /src | |
| parent | 14758a47201477ce0dd277b1f3711609719992c6 (diff) | |
Generic div_round_up()native
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1,4 +1,4 @@ -use std::ops::{Add, Sub, Mul}; +use std::ops::{Add, Sub, Div}; pub struct BCH { m: i16, @@ -8,10 +8,14 @@ pub struct BCH { n:i16, } -fn div_round_up(a: i16, b: i16) -> i16 { - (a + b - 1) / b +pub fn div_round_up<T>(a: T, b: T) -> T +where + T: Copy + Add<Output = T> + Sub<Output = T> + Div<Output = T> + From<u8>, +{ + (a + b - T::from(1)) / b } + impl BCH { pub fn build_gf_tables(self) { |
