38 lines
966 B
Rust
38 lines
966 B
Rust
|
use bnum::cast::As;
|
||
|
|
||
|
type Planar64=fixed::types::I32F32;
|
||
|
type Planar64Wide1=fixed::types::I64F64;
|
||
|
type Planar64Wide2=bnum::types::I256;
|
||
|
type Planar64Wide3=bnum::types::I512;
|
||
|
//wouldn't that be nice
|
||
|
//type Planar64Wide2=fixed::FixedI256<fixed::types::extra::U128>;
|
||
|
//type Planar64Wide3=fixed::FixedI512<fixed::types::extra::U256>;
|
||
|
|
||
|
pub fn wide_mul(left: Planar64, right: Planar64) -> Planar64Wide1 {
|
||
|
left.wide_mul(right)
|
||
|
}
|
||
|
pub fn wide_mul_2(left: Planar64Wide1, right: Planar64Wide1) -> Planar64Wide2 {
|
||
|
Planar64Wide2::from(left.to_bits())*Planar64Wide2::from(right.to_bits())
|
||
|
}
|
||
|
pub fn wide_mul_3(left: Planar64Wide2, right: Planar64Wide2) -> Planar64Wide3 {
|
||
|
left.as_::<Planar64Wide3>()*right.as_::<Planar64Wide3>()
|
||
|
}
|
||
|
|
||
|
#[cfg(test)]
|
||
|
mod tests {
|
||
|
use super::*;
|
||
|
|
||
|
#[test]
|
||
|
fn it_works() {
|
||
|
let result = add(2.into(), 2.into());
|
||
|
assert_eq!(result, 4);
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
pub fn main(){
|
||
|
let a=6f128;
|
||
|
let max=i32::MAX as i64;
|
||
|
println!("{} {}",max*max,i64::MAX);
|
||
|
}
|
||
|
}
|