From 0779352b1855f7789f935ff6600af638a35c7ea1 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 09:58:12 -0700 Subject: [PATCH 01/86] update bnum to 0.14.0 --- Cargo.lock | 4 +- engine/physics/src/face_crawler.rs | 22 ++- engine/physics/src/minimum_difference.rs | 13 +- engine/physics/src/model.rs | 13 +- engine/physics/src/push_solve.rs | 3 +- lib/common/src/integer.rs | 12 +- lib/fixed_wide/Cargo.toml | 2 +- lib/fixed_wide/src/fixed.rs | 235 ++++++++++++----------- lib/fixed_wide/src/tests.rs | 2 +- lib/fixed_wide/src/types.rs | 9 +- 10 files changed, 166 insertions(+), 149 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a1335e7..39b5dee0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -433,9 +433,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.13.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119771309b95163ec7aaf79810da82f7cd0599c19722d48b9c03894dca833966" +checksum = "7d14a3912e1478234033344e1817fc1bdd0e8b088658922101cf9c8e5dbc96f6" [[package]] name = "bstr" diff --git a/engine/physics/src/face_crawler.rs b/engine/physics/src/face_crawler.rs index dc2d9541..f99aa134 100644 --- a/engine/physics/src/face_crawler.rs +++ b/engine/physics/src/face_crawler.rs @@ -1,5 +1,7 @@ use crate::model::{into_giga_time,GigaTime}; -use strafesnet_common::integer::{Fixed,Ratio,vec3::Vector3,Planar64Vec3}; +use strafesnet_common::integer::fixed_types::{I32F32,I64F64,I128F128}; +use strafesnet_common::integer::vec3::Vector3; +use strafesnet_common::integer::{Fixed,Ratio,Planar64Vec3}; use crate::physics::{Time,Trajectory}; use crate::mesh_query::{FEV,DirectedEdge,MeshQuery,MeshTopology}; @@ -65,16 +67,16 @@ where } } -impl,Offset=Fixed<4,128>,Position=Planar64Vec3,Direction=Planar64Vec3>> FEV +impl,Offset=I128F128,Position=Planar64Vec3,Direction=Planar64Vec3>> FEV where // This is hardcoded for MinkowskiMesh lol M::Face:Copy, M::Edge:Copy, M::DirectedEdge:Copy, M::Vert:Copy, - F:core::ops::Mul,Output=Fixed<4,128>>, - >>::Output:core::iter::Sum, - M::Offset:core::ops::Sub<>>::Output>, + F:core::ops::Mul, + >::Output:core::iter::Sum, + M::Offset:core::ops::Sub<>::Output>, { fn next_transition(&self,mesh:&M,trajectory:&Trajectory,lower_bound:Bound,mut upper_bound:Bound)->Transition{ //conflicting derivative means it crosses in the wrong direction. @@ -88,7 +90,7 @@ impl,Offset=Fixed<4,128>,Position=Planar64V let (n,d)=mesh.face_nd(face_id); //TODO: use higher precision d value? //use the mesh transform translation instead of baking it into the d value. - for dt in Fixed::<4,128>::zeroes2((n.dot(trajectory.position)-d)*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ + for dt in I128F128::zeroes2((n.dot(trajectory.position)-d)*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ upper_bound=Bound::Included(dt); best_transition=Transition::Hit(face_id,dt); @@ -103,7 +105,7 @@ impl,Offset=Fixed<4,128>,Position=Planar64V //WARNING: d is moved out of the *2 block because of adding two vertices! //WARNING: precision is swept under the rug! //wrap for speed - for dt in Fixed::<4,128>::zeroes2(n.dot(trajectory.position*2-(mesh.vert(v0)+mesh.vert(v1))).wrap_4(),n.dot(trajectory.velocity).wrap_4()*2,n.dot(trajectory.acceleration).wrap_4()){ + for dt in I128F128::zeroes2(n.dot(trajectory.position*2-(mesh.vert(v0)+mesh.vert(v1))).wrap_4(),n.dot(trajectory.velocity).wrap_4()*2,n.dot(trajectory.acceleration).wrap_4()){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ upper_bound=Bound::Included(dt); best_transition=Transition::Next(FEV::Edge(directed_edge_id.as_undirected()),dt); @@ -126,7 +128,7 @@ impl,Offset=Fixed<4,128>,Position=Planar64V let n=face_n.cross(edge_n)*((i as i64)*2-1); //WARNING yada yada d *2 //wrap for speed - for dt in Fixed::<4,128>::zeroes2(n.dot(delta_pos).wrap_4(),n.dot(trajectory.velocity).wrap_4()*2,n.dot(trajectory.acceleration).wrap_4()){ + for dt in I128F128::zeroes2(n.dot(delta_pos).wrap_4(),n.dot(trajectory.velocity).wrap_4()*2,n.dot(trajectory.acceleration).wrap_4()){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ upper_bound=Bound::Included(dt); best_transition=Transition::Next(FEV::Face(edge_face_id),dt); @@ -138,7 +140,7 @@ impl,Offset=Fixed<4,128>,Position=Planar64V for (i,&vert_id) in edge_verts.as_ref().iter().enumerate(){ //vertex normal gets parity from vert index let n=edge_n*(1-2*(i as i64)); - for dt in Fixed::<2,64>::zeroes2((n.dot(trajectory.position-mesh.vert(vert_id)))*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ + for dt in I64F64::zeroes2((n.dot(trajectory.position-mesh.vert(vert_id)))*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ let dt=Ratio::new(dt.num.widen_4(),dt.den.widen_4()); upper_bound=Bound::Included(dt); @@ -154,7 +156,7 @@ impl,Offset=Fixed<4,128>,Position=Planar64V mesh.for_each_vert_edge(vert_id,|directed_edge_id|{ //edge is directed away from vertex, but we want the dot product to turn out negative let n=-mesh.directed_edge_n(directed_edge_id); - for dt in Fixed::<2,64>::zeroes2((n.dot(trajectory.position-mesh.vert(vert_id)))*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ + for dt in I64F64::zeroes2((n.dot(trajectory.position-mesh.vert(vert_id)))*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ let dt=Ratio::new(dt.num.widen_4(),dt.den.widen_4()); upper_bound=Bound::Included(dt); diff --git a/engine/physics/src/minimum_difference.rs b/engine/physics/src/minimum_difference.rs index 2dfd0878..f6fb82b1 100644 --- a/engine/physics/src/minimum_difference.rs +++ b/engine/physics/src/minimum_difference.rs @@ -1,3 +1,4 @@ +use strafesnet_common::integer::fixed_types::{I64F64,I96F96,I128F128}; use strafesnet_common::integer::vec3; use strafesnet_common::integer::vec3::Vector3; use strafesnet_common::integer::{Fixed,Planar64,Planar64Vec3}; @@ -100,7 +101,7 @@ const fn choose_any_direction()->Planar64Vec3{ vec3::X } -fn narrow_dir2(dir:Vector3>)->Planar64Vec3{ +fn narrow_dir2(dir:Vector3)->Planar64Vec3{ if dir==vec3::zero(){ return dir.narrow_1().unwrap(); } @@ -115,7 +116,7 @@ fn narrow_dir2(dir:Vector3>)->Planar64Vec3{ dir }.narrow_1().unwrap() } -fn narrow_dir3(dir:Vector3>)->Planar64Vec3{ +fn narrow_dir3(dir:Vector3)->Planar64Vec3{ if dir==vec3::zero(){ return dir.narrow_1().unwrap(); } @@ -565,8 +566,8 @@ trait Contains{ // convenience type to check if a point is within some threshold of a plane. struct ThickPlane{ point:Planar64Vec3, - normal:Vector3>, - epsilon:Fixed<3,96>, + normal:Vector3, + epsilon:I96F96, } impl ThickPlane{ fn new>(mesh:&M,[v0,v1,v2]:Simplex<3,M::Vert>)->Self{ @@ -590,7 +591,7 @@ impl Contains for ThickPlane{ struct ThickLine{ point:Planar64Vec3, dir:Planar64Vec3, - epsilon:Fixed<4,128>, + epsilon:I128F128, } impl ThickLine{ fn new>(mesh:&M,[v0,v1]:Simplex<2,M::Vert>)->Self{ @@ -613,7 +614,7 @@ impl Contains for ThickLine{ struct EVFinder<'a,M,C>{ mesh:&'a M, constraint:C, - best_distance_squared:Fixed<2,64>, + best_distance_squared:I64F64, } impl,C:Contains> EVFinder<'_,M,C> diff --git a/engine/physics/src/model.rs b/engine/physics/src/model.rs index 8c8b6822..125937cb 100644 --- a/engine/physics/src/model.rs +++ b/engine/physics/src/model.rs @@ -1,4 +1,5 @@ use std::collections::{HashSet,HashMap}; +use strafesnet_common::integer::fixed_types::{I64F64,I96F96,I128F128}; use strafesnet_common::integer::vec3::Vector3; use strafesnet_common::model::{self,MeshId,PolygonIter}; use strafesnet_common::integer::{self,vec3,Fixed,Planar64,Planar64Vec3,Ratio}; @@ -461,8 +462,8 @@ impl MeshTopology for PhysicsMeshView<'_>{ #[derive(Debug)] pub struct PhysicsMeshTransform{ pub vertex:integer::Planar64Affine3, - pub normal:integer::mat3::Matrix3>, - pub det:Fixed<3,96>, + pub normal:integer::mat3::Matrix3, + pub det:I96F96, } impl PhysicsMeshTransform{ pub fn new(transform:integer::Planar64Affine3)->Self{ @@ -489,15 +490,15 @@ impl TransformedMesh<'_>{ transform, } } - pub fn verts<'a>(&'a self)->impl Iterator>>+'a{ + pub fn verts<'a>(&'a self)->impl Iterator>+'a{ self.view.data.verts.iter().map(|&Vert(pos)|self.transform.vertex.transform_point3(pos)) } } impl MeshQuery for TransformedMesh<'_>{ type Direction=Planar64Vec3; type Position=Planar64Vec3; - type Normal=Vector3>; - type Offset=Fixed<4,128>; + type Normal=Vector3; + type Offset=I128F128; fn face_nd(&self,face_id:SubmeshFaceId)->(Self::Normal,Self::Offset){ let (n,d)=self.view.face_nd(face_id); let transformed_n=self.transform.normal*n; @@ -562,7 +563,7 @@ impl MeshTopology for TransformedMesh<'_>{ } } -pub type GigaTime=Ratio,Fixed<4,128>>; +pub type GigaTime=Ratio; pub fn into_giga_time(time:Time,relative_to:Time)->GigaTime{ let r=(time-relative_to).to_ratio(); Ratio::new(r.num.widen_4(),r.den.widen_4()) diff --git a/engine/physics/src/push_solve.rs b/engine/physics/src/push_solve.rs index 896e39cb..0d2c698c 100644 --- a/engine/physics/src/push_solve.rs +++ b/engine/physics/src/push_solve.rs @@ -1,3 +1,4 @@ +use strafesnet_common::integer::fixed_types::I32F32; use strafesnet_common::integer::vec3::{self,Vector3}; use strafesnet_common::integer::{Fixed,Planar64Vec3,Ratio}; use strafesnet_common::ray::Ray; @@ -12,7 +13,7 @@ use strafesnet_common::ray::Ray; type Conts<'a>=arrayvec::ArrayVec<&'a Contact,4>; // hack to allow comparing ratios to zero -const RATIO_ZERO:Ratio,Fixed<1,32>>=Ratio::new(Fixed::ZERO,Fixed::EPSILON); +const RATIO_ZERO:Ratio=Ratio::new(Fixed::ZERO,Fixed::EPSILON); /// Information about a contact restriction #[derive(Debug,PartialEq)] diff --git a/lib/common/src/integer.rs b/lib/common/src/integer.rs index 33f9d2a6..0105ada0 100644 --- a/lib/common/src/integer.rs +++ b/lib/common/src/integer.rs @@ -1,6 +1,12 @@ pub use fixed_wide::fixed::*; pub use ratio_ops::ratio::{Ratio,Divide,Parity}; +pub mod fixed_types{ + pub use fixed_wide::types::*; +} + +use fixed_wide::types::{I32F32,I64F64}; + //integer units /// specific example of a "default" time type @@ -137,7 +143,7 @@ impl std::ops::Mul for Time{ type Output=Ratio,Fixed<2,64>>; #[inline] fn mul(self,rhs:Self)->Self::Output{ - Ratio::new(Fixed::raw(self.0)*Fixed::raw(rhs.0),Fixed::raw_digit(1_000_000_000i64.pow(2))) + Ratio::new(Fixed::raw(self.0)*Fixed::raw(rhs.0),Fixed::from_u64(1_000_000_000u64.pow(2))) } } macro_rules! impl_time_i64_rhs_operator { @@ -191,13 +197,13 @@ mod test_time{ #[test] fn time_squared(){ let a=Time::from_secs(2); - assert_eq!(a*a,Ratio::new(Fixed::<2,64>::raw_digit(1_000_000_000i64.pow(2))*4,Fixed::<2,64>::raw_digit(1_000_000_000i64.pow(2)))); + assert_eq!(a*a,Ratio::new(I64F64::from_u64(1_000_000_000u64.pow(2))*4,I64F64::from_u64(1_000_000_000u64.pow(2)))); } #[test] fn time_times_planar64(){ let a=Time::from_secs(2); let b=Planar64::from(2); - assert_eq!(b*a,Ratio::new(Fixed::<2,64>::raw_digit(1_000_000_000*(1<<32))<<2,Fixed::<1,32>::raw_digit(1_000_000_000))); + assert_eq!(b*a,Ratio::new(I64F64::from_u64(1_000_000_000*(1<<32))<<2,I32F32::from_u64(1_000_000_000))); } } diff --git a/lib/fixed_wide/Cargo.toml b/lib/fixed_wide/Cargo.toml index 0cc0d744..11ae338e 100644 --- a/lib/fixed_wide/Cargo.toml +++ b/lib/fixed_wide/Cargo.toml @@ -14,7 +14,7 @@ wide-mul=[] zeroes=["dep:arrayvec"] [dependencies] -bnum = "0.13.0" +bnum = "0.14.2" arrayvec = { version = "0.7.6", optional = true } paste = "1.0.15" ratio_ops = { workspace = true, optional = true } diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 055f671e..6669b5da 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -1,54 +1,59 @@ -use bnum::{BInt,cast::As}; +use bnum::{Int,cast::As,n}; -const BNUM_DIGIT_WIDTH:usize=64; +const BNUM_DIGIT_WIDTH:usize=8; +/// how many bnum 14 digits are there per bnum 13 digit +const BNUM_13_COMPAT:usize=64/8; #[derive(Clone,Copy,Default,Hash,PartialEq,Eq,PartialOrd,Ord)] /// A Fixed point number for which multiply operations widen the bits in the output. (when the wide-mul feature is enabled) -/// N is the number of u64s to use -/// F is the number of fractional bits (always N*32 lol) +/// N is the number of u8s to use +/// F is the number of fractional bits (currently always N*8/2) pub struct Fixed{ - bits:BInt<{N}>, + bits:Int, } impl Fixed{ - pub const MAX:Self=Self::from_bits(BInt::::MAX); - pub const MIN:Self=Self::from_bits(BInt::::MIN); - pub const ZERO:Self=Self::from_bits(BInt::::ZERO); - pub const EPSILON:Self=Self::from_bits(BInt::::ONE); - pub const NEG_EPSILON:Self=Self::from_bits(BInt::::NEG_ONE); - pub const ONE:Self=Self::from_bits(BInt::::ONE.shl(F as u32)); - pub const TWO:Self=Self::from_bits(BInt::::TWO.shl(F as u32)); - pub const HALF:Self=Self::from_bits(BInt::::ONE.shl(F as u32-1)); - pub const NEG_ONE:Self=Self::from_bits(BInt::::NEG_ONE.shl(F as u32)); - pub const NEG_TWO:Self=Self::from_bits(BInt::::NEG_TWO.shl(F as u32)); - pub const NEG_HALF:Self=Self::from_bits(BInt::::NEG_ONE.shl(F as u32-1)); + pub const MAX:Self=Self::from_bits(Int::::MAX); + pub const MIN:Self=Self::from_bits(Int::::MIN); + pub const ZERO:Self=Self::from_bits(n!(0)); + pub const EPSILON:Self=Self::from_bits(n!(1)); + pub const NEG_EPSILON:Self=Self::from_bits(n!(-1)); + pub const ONE:Self=Self::from_bits(n!(1).shl(F as u32)); + pub const TWO:Self=Self::from_bits(n!(2).shl(F as u32)); + pub const HALF:Self=Self::from_bits(n!(1).shl(F as u32-1)); + pub const NEG_ONE:Self=Self::from_bits(n!(-1).shl(F as u32)); + pub const NEG_TWO:Self=Self::from_bits(n!(-2).shl(F as u32)); + pub const NEG_HALF:Self=Self::from_bits(n!(-1).shl(F as u32-1)); } impl Fixed{ #[inline] - pub const fn from_bits(bits:BInt::)->Self{ + pub const fn from_bits(bits:Int::)->Self{ Self{ bits, } } #[inline] - pub const fn to_bits(self)->BInt{ + pub const fn to_bits(self)->Int{ self.bits } #[inline] - pub const fn as_bits(&self)->&BInt{ + pub const fn as_bits(&self)->&Int{ &self.bits } #[inline] - pub const fn as_bits_mut(&mut self)->&mut BInt{ + pub const fn as_bits_mut(&mut self)->&mut Int{ &mut self.bits } #[inline] - pub const fn raw_digit(value:i64)->Self{ - let mut digits=[0u64;N]; - digits[0]=value.abs() as u64; - //sign bit - digits[N-1]|=(value&i64::MIN) as u64; - Self::from_bits(BInt::from_bits(bnum::BUint::from_digits(digits))) + pub const fn from_u64(value:u64)->Self{ + let mut digits=Self::ZERO; + let bytes=value.to_ne_bytes(); + let mut digit=0; + while digitbool{ @@ -99,26 +104,25 @@ impl Fixed{ } } } -impl Fixed<1,F>{ +impl Fixed<8,F>{ /// My old code called this function everywhere so let's provide it #[inline] pub const fn raw(value:i64)->Self{ - Self::from_bits(BInt::from_bits(bnum::BUint::from_digit(value as u64))) + Self::from_bits(Int::from_bytes(value.to_ne_bytes())) } #[inline] pub const fn to_raw(self)->i64{ - let &[digit]=self.to_bits().to_bits().digits(); - digit as i64 + i64::from_ne_bytes(self.to_bits().to_bytes()) } } -macro_rules! impl_from { +macro_rules! impl_from{ ($($from:ty),*)=>{ $( impl From<$from> for Fixed{ #[inline] fn from(value:$from)->Self{ - Self::from_bits(BInt::<{N}>::from(value)<>()< std::iter::Sum for Fixed{ } } -const fn signed_shift(lhs:u64,rhs:i32)->u64{ +const fn signed_shift(lhs:u8,rhs:i32)->u8{ if rhs.is_negative(){ lhs>>-rhs }else{ @@ -159,12 +163,12 @@ macro_rules! impl_into_float { impl Into<$output> for Fixed{ #[inline] fn into(self)->$output{ - const DIGIT_SHIFT:u32=6;//Log2[64] + const DIGIT_SHIFT:u32=3;//Log2[BNUM_DIGIT_WIDTH] // SBBB BBBB // 1001 1110 0000 0000 let sign=if self.bits.is_negative(){(1 as $unsigned)<<(<$unsigned>::BITS-1)}else{0}; let unsigned=self.bits.unsigned_abs(); - let most_significant_bit=unsigned.bits(); + let most_significant_bit=unsigned.bit_width(); let exp=if unsigned.is_zero(){ 0 }else{ @@ -173,12 +177,13 @@ macro_rules! impl_into_float { let msb_offset=msb+_127-1-F as $unsigned; msb_offset<<($mantissa_bits-1) }; - let digits=unsigned.digits(); + let digits=unsigned.to_bytes(); let digit_index=most_significant_bit.saturating_sub(1)>>DIGIT_SHIFT; let digit=digits[digit_index as usize]; //How many bits does the mantissa take from this digit let take_bits=most_significant_bit-(digit_index<Result{ - const DIGIT_SHIFT:u32=6; + const DIGIT_SHIFT:u32=3;//Log[BNUM_DIGIT_WIDTH] match value.classify(){ std::num::FpCategory::Nan=>Err(FixedFromFloatError::Nan), std::num::FpCategory::Infinite=>Err(FixedFromFloatError::Infinite), @@ -261,7 +266,7 @@ macro_rules! impl_from_float { |std::num::FpCategory::Normal =>{ let (m,e,s)=$decode(value); - let mut digits=[0u64;N]; + let mut digits=[0u8;N]; let most_significant_bit=e as i32+$mantissa_bits as i32+F as i32; if most_significant_bit<0{ return Err(FixedFromFloatError::Underflow); @@ -279,7 +284,7 @@ macro_rules! impl_from_float { *digit=signed_shift(m,rest_of_mantissa); } } - let bits=BInt::from_bits(bnum::BUint::from_digits(digits)); + let bits=Int::from_bits(bnum::Uint::from_digits(digits)); Ok(if s{ Self::from_bits(bits.overflowing_neg().0) }else{ @@ -298,7 +303,7 @@ impl core::fmt::Debug for Fixed{ #[inline] fn fmt(&self,f:&mut core::fmt::Formatter)->Result<(),core::fmt::Error>{ let integral=self.as_bits().unsigned_abs()>>F; - let fractional=self.as_bits().unsigned_abs()&((bnum::BUint::::ONE<::ONE); + let fractional=self.as_bits().unsigned_abs()&((bnum::Uint::::ONE<::ONE); let leading_zeroes=(fractional.leading_zeros() as usize).saturating_sub(N*BNUM_DIGIT_WIDTH-F)>>2; if self.is_negative(){ core::write!(f,"-")?; @@ -400,7 +405,7 @@ macro_rules! impl_multiply_operator_not_const_generic { #[inline] pub fn [](self, rhs: Self) -> Self { let (low,high)=self.bits.unsigned_abs().widening_mul(rhs.bits.unsigned_abs()); - let out:BInt::<{$width*2}>=unsafe{core::mem::transmute([low,high])}; + let out:Int::<{$width*2}>=unsafe{core::mem::transmute([low,high])}; if self.is_negative()==rhs.is_negative(){ Self::from_bits(out.shr(F as u32).as_()) }else{ @@ -412,11 +417,11 @@ macro_rules! impl_multiply_operator_not_const_generic { #[cfg(not(feature="wide-mul"))] impl_multiplicative_operator_not_const_generic!(($struct, $trait, $method, $output ), $width); #[cfg(feature="deferred-division")] - impl ratio_ops::ratio::Divide for Fixed<$width,{$width*32}>{ + impl ratio_ops::ratio::Divide for Fixed<{$width/BNUM_DIGIT_WIDTH},{$width>>1}>{ type Output=Self; #[inline] fn divide(self, other: i64)->Self::Output{ - Self::from_bits(self.bits.div_euclid(BInt::from(other))) + Self::from_bits(self.bits.div_euclid(other.as_())) } } } @@ -428,8 +433,8 @@ macro_rules! impl_divide_operator_not_const_generic { #[inline] pub fn [](self,other:Self)->Self{ //this only needs to be $width+F as u32/64+1 but MUH CONST GENERICS!!!!! - let lhs=self.bits.as_::>().shl(F as u32); - let rhs=other.bits.as_::>(); + let lhs=self.bits.as_::>().shl(F as u32); + let rhs=other.bits.as_::>(); Self::from_bits(lhs.div_euclid(rhs).as_()) } } @@ -453,12 +458,12 @@ macro_rules! impl_multiplicative_operator { ( $struct: ident, $trait: ident, $method: ident, $inner_method: ident, $output: ty ) => { impl core::ops::$trait for $struct where - BInt:::From+core::ops::$trait, + Int:::From+core::ops::$trait, { type Output = $output; #[inline] fn $method(self,other:U)->Self::Output{ - Self::from_bits(self.bits.$inner_method(BInt::::from(other))) + Self::from_bits(self.bits.$inner_method(Int::::from(other))) } } }; @@ -467,11 +472,11 @@ macro_rules! impl_multiplicative_assign_operator { ( $struct: ident, $trait: ident, $method: ident, $not_assign_method: ident ) => { impl core::ops::$trait for $struct where - BInt:::From+core::ops::$trait, + Int:::From+core::ops::$trait, { #[inline] fn $method(&mut self,other:U){ - self.bits=self.bits.$not_assign_method(BInt::::from(other)); + self.bits=self.bits.$not_assign_method(Int::::from(other)); } } }; @@ -548,30 +553,30 @@ impl_shift_operator!( Fixed, Shr, shr, Self ); #[allow(unused_macros)] macro_rules! impl_wide_operators{ ($lhs:expr,$rhs:expr)=>{ - impl core::ops::Mul> for Fixed<$lhs,{$lhs*32}>{ - type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>; + impl core::ops::Mul>1}>> for Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}>{ + type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)>>1}>; #[inline] - fn mul(self, other: Fixed<$rhs,{$rhs*32}>)->Self::Output{ + fn mul(self, other: Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Self::Output{ paste::item!{ self.[](other) } } } #[cfg(not(feature="deferred-division"))] - impl core::ops::Div> for Fixed<$lhs,{$lhs*32}>{ - type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>; + impl core::ops::Div>1}>> for Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}>{ + type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)>>1}>; #[inline] - fn div(self, other: Fixed<$rhs,{$rhs*32}>)->Self::Output{ + fn div(self, other: Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Self::Output{ paste::item!{ self.[](other) } } } #[cfg(feature="deferred-division")] - impl ratio_ops::ratio::Divide> for Fixed<$lhs,{$lhs*32}>{ - type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>; + impl ratio_ops::ratio::Divide>1}>> for Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}>{ + type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)>>1}>; #[inline] - fn divide(self, other: Fixed<$rhs,{$rhs*32}>)->Self::Output{ + fn divide(self, other: Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Self::Output{ paste::item!{ self.[](other) } @@ -588,23 +593,23 @@ macro_rules! impl_wide_not_const_generic{ (), ($lhs:expr,$rhs:expr) )=>{ - impl Fixed<$lhs,{$lhs*32}> + impl Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}> { paste::item!{ #[inline] - pub fn [](self,rhs:Fixed<$rhs,{$rhs*32}>)->Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>{ - let lhs=self.bits.as_::>(); - let rhs=rhs.bits.as_::>(); + pub fn [](self,rhs:Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Fixed<{$lhs+$rhs},{($lhs+$rhs)>>1}>{ + let lhs=self.bits.as_::>(); + let rhs=rhs.bits.as_::>(); Fixed::from_bits(lhs*rhs) } /// This operation cannot represent the fraction exactly, /// but it shapes the output to have precision for the /// largest and smallest possible fractions. #[inline] - pub fn [](self,rhs:Fixed<$rhs,{$rhs*32}>)->Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>{ + pub fn [](self,rhs:Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Fixed<{$lhs+$rhs},{($lhs+$rhs)>>1}>{ // (lhs/2^LHS_FRAC)/(rhs/2^RHS_FRAC) - let lhs=self.bits.as_::>().shl($rhs*64); - let rhs=rhs.bits.as_::>(); + let lhs=self.bits.as_::>().shl($rhs); + let rhs=rhs.bits.as_::>(); Fixed::from_bits(lhs.div_euclid(rhs)) } } @@ -618,13 +623,13 @@ macro_rules! impl_wide_same_size_not_const_generic{ (), $width:expr )=>{ - impl Fixed<$width,{$width*32}> + impl Fixed<{$width/BNUM_DIGIT_WIDTH},{$width>>1}> { paste::item!{ #[inline] - pub fn [](self,rhs:Fixed<$width,{$width*32}>)->Fixed<{$width*2},{$width*2*32}>{ + pub fn [](self,rhs:Fixed<{$width/BNUM_DIGIT_WIDTH},{$width>>1}>)->Fixed<{$width*2},{$width*2>>1}>{ let (low,high)=self.bits.unsigned_abs().widening_mul(rhs.bits.unsigned_abs()); - let out:BInt::<{$width*2}>=unsafe{core::mem::transmute([low,high])}; + let out:Int::<{$width*2}>=unsafe{core::mem::transmute([low,high])}; if self.is_negative()==rhs.is_negative(){ Fixed::from_bits(out) }else{ @@ -637,10 +642,10 @@ macro_rules! impl_wide_same_size_not_const_generic{ /// but it shapes the output to have precision for the /// largest and smallest possible fractions. #[inline] - pub fn [](self,rhs:Fixed<$width,{$width*32}>)->Fixed<{$width*2},{$width*2*32}>{ + pub fn [](self,rhs:Fixed<{$width/BNUM_DIGIT_WIDTH},{$width>>1}>)->Fixed<{$width*2},{$width*2>>1}>{ // (lhs/2^LHS_FRAC)/(rhs/2^RHS_FRAC) - let lhs=self.bits.as_::>().shl($width*64); - let rhs=rhs.bits.as_::>(); + let lhs=self.bits.as_::>().shl($width); + let rhs=rhs.bits.as_::>(); Fixed::from_bits(lhs.div_euclid(rhs)) } } @@ -653,7 +658,7 @@ macro_rules! impl_wide_same_size_not_const_generic{ //const generics sidestepped wahoo macro_repeated!( impl_wide_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1),(14,1),(15,1), + (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1),(14,1),(960,1), (1,2), (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(9,2),(10,2),(11,2),(12,2),(13,2),(14,2), (1,3),(2,3), (4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(10,3),(11,3),(12,3),(13,3), (1,4),(2,4),(3,4), (5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(11,4),(12,4), @@ -667,7 +672,7 @@ macro_repeated!( (1,12),(2,12),(3,12),(4,12), (1,13),(2,13),(3,13), (1,14),(2,14), - (1,15) + (1,960) ); macro_repeated!( impl_wide_same_size_not_const_generic,(), @@ -702,43 +707,43 @@ macro_rules! impl_narrow_not_const_generic{ ($lhs:expr,$rhs:expr) )=>{ paste::item!{ - impl Fixed<$lhs,{$lhs*32}> + impl Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}> { #[inline] - pub fn [](self)->Fixed<$rhs,{$rhs*32}>{ - Fixed::from_bits(bnum::cast::As::as_::>(self.bits.shr(($lhs-$rhs)*32))) + pub fn [](self)->Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>{ + Fixed::from_bits(bnum::cast::As::as_::>(self.bits.shr(($lhs-$rhs)>>1))) } #[inline] - pub fn [](self)->Result,NarrowError>{ - if Fixed::<$rhs,{$rhs*32}>::MAX.[]().bits](self)->Result>1}>,NarrowError>{ + if Fixed::<$rhs,{$rhs>>1}>::MAX.[]().bits::MIN.[]().bits{ + if self.bits>1}>::MIN.[]().bits{ return Err(NarrowError::Underflow); } Ok(self.[]()) } #[inline] - pub fn [](self)->Fixed<$rhs,{$rhs*32}>{ + pub fn [](self)->Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>{ self.[]().clamp() } } - impl Wrap> for Fixed<$lhs,{$lhs*32}>{ + impl Wrap>1}>> for Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}>{ #[inline] - fn wrap(self)->Fixed<$rhs,{$rhs*32}>{ + fn wrap(self)->Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>{ self.[]() } } - impl TryInto> for Fixed<$lhs,{$lhs*32}>{ + impl TryInto>1}>> for Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}>{ type Error=NarrowError; #[inline] - fn try_into(self)->Result,Self::Error>{ + fn try_into(self)->Result>1}>,Self::Error>{ self.[]() } } - impl Clamp> for Fixed<$lhs,{$lhs*32}>{ + impl Clamp>1}>> for Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}>{ #[inline] - fn clamp(self)->Fixed<$rhs,{$rhs*32}>{ + fn clamp(self)->Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>{ self.[]() } } @@ -751,16 +756,16 @@ macro_rules! impl_widen_not_const_generic{ ($lhs:expr,$rhs:expr) )=>{ paste::item!{ - impl Fixed<$lhs,{$lhs*32}> + impl Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}> { #[inline] - pub fn [](self)->Fixed<$rhs,{$rhs*32}>{ - Fixed::from_bits(bnum::cast::As::as_::>(self.bits).shl(($rhs-$lhs)*32)) + pub fn [](self)->Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>{ + Fixed::from_bits(bnum::cast::As::as_::>(self.bits).shl(($rhs-$lhs)>>1)) } } - impl Into> for Fixed<$lhs,{$lhs*32}>{ + impl Into>1}>> for Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}>{ #[inline] - fn into(self)->Fixed<$rhs,{$rhs*32}>{ + fn into(self)->Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>{ self.[]() } } @@ -772,21 +777,21 @@ macro_rules! impl_widen_not_const_generic{ macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1),(14,1),(15,1),(16,1),(17,1), - (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(9,2),(10,2),(11,2),(12,2),(13,2),(14,2),(15,2),(16,2), - (4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(10,3),(11,3),(12,3),(13,3),(14,3),(15,3),(16,3), - (5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(11,4),(12,4),(13,4),(14,4),(15,4),(16,4), - (6,5),(7,5),(8,5),(9,5),(10,5),(11,5),(12,5),(13,5),(14,5),(15,5),(16,5), - (7,6),(8,6),(9,6),(10,6),(11,6),(12,6),(13,6),(14,6),(15,6),(16,6), - (8,7),(9,7),(10,7),(11,7),(12,7),(13,7),(14,7),(15,7),(16,7), - (9,8),(10,8),(11,8),(12,8),(13,8),(14,8),(15,8),(16,8), - (10,9),(11,9),(12,9),(13,9),(14,9),(15,9),(16,9), - (11,10),(12,10),(13,10),(14,10),(15,10),(16,10), - (12,11),(13,11),(14,11),(15,11),(16,11), - (13,12),(14,12),(15,12),(16,12), - (14,13),(15,13),(16,13), - (15,14),(16,14), - (16,15) + (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1),(14,1),(960,1),(1024,1),(1088,1), + (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(9,2),(10,2),(11,2),(12,2),(13,2),(14,2),(960,2),(1024,2), + (4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(10,3),(11,3),(12,3),(13,3),(14,3),(960,3),(1024,3), + (5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(11,4),(12,4),(13,4),(14,4),(960,4),(1024,4), + (6,5),(7,5),(8,5),(9,5),(10,5),(11,5),(12,5),(13,5),(14,5),(960,5),(1024,5), + (7,6),(8,6),(9,6),(10,6),(11,6),(12,6),(13,6),(14,6),(960,6),(1024,6), + (8,7),(9,7),(10,7),(11,7),(12,7),(13,7),(14,7),(960,7),(1024,7), + (9,8),(10,8),(11,8),(12,8),(13,8),(14,8),(960,8),(1024,8), + (10,9),(11,9),(12,9),(13,9),(14,9),(960,9),(1024,9), + (11,10),(12,10),(13,10),(14,10),(960,10),(1024,10), + (12,11),(13,11),(14,11),(960,11),(1024,11), + (13,12),(14,12),(960,12),(1024,12), + (14,13),(960,13),(1024,13), + (960,14),(1024,14), + (1024,960) ); macro_repeated!( impl_widen_not_const_generic,(), @@ -803,14 +808,14 @@ macro_repeated!( (1,12),(2,12),(3,12),(4,12),(5,12),(6,12),(7,12),(8,12),(9,12),(10,12),(11,12), (1,13),(2,13),(3,13),(4,13),(5,13),(6,13),(7,13),(8,13),(9,13),(10,13),(11,13),(12,13), (1,14),(2,14),(3,14),(4,14),(5,14),(6,14),(7,14),(8,14),(9,14),(10,14),(11,14),(12,14),(13,14), - (1,15),(2,15),(3,15),(4,15),(5,15),(6,15),(7,15),(8,15),(9,15),(10,15),(11,15),(12,15),(13,15),(14,15), - (1,16),(2,16),(3,16),(4,16),(5,16),(6,16),(7,16),(8,16),(9,16),(10,16),(11,16),(12,16),(13,16),(14,16),(15,16), - (1,17) + (1,960),(2,960),(3,960),(4,960),(5,960),(6,960),(7,960),(8,960),(9,960),(10,960),(11,960),(12,960),(13,960),(14,960), + (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(6,1024),(7,1024),(8,1024),(9,1024),(10,1024),(11,1024),(12,1024),(13,1024),(14,1024),(960,1024), + (1,1088) ); macro_rules! impl_not_const_generic{ ($n:expr,$_2n:expr)=>{ - impl Fixed<$n,{$n*32}>{ + impl Fixed<$n,{$n>>1}>{ paste::item!{ #[inline] pub fn sqrt_unchecked(self)->Self{ @@ -820,18 +825,18 @@ macro_rules! impl_not_const_generic{ //2. divide by 2 via >>1 (sqrt-ish) //3. add on fractional offset //Voila - let used_bits=self.bits.bits() as i32-1-($n*32) as i32; - let max_shift=((used_bits>>1)+($n*32) as i32) as u32; + let used_bits=self.bits.unsigned_abs().bit_width() as i32-1-($n>>1) as i32; + let max_shift=((used_bits>>1)+($n>>1) as i32) as u32; let mut result=Self::ZERO; //resize self to match the wide mul output let wide_self=self.[](); //descend down the bits and check if flipping each bit would push the square over the input value for shift in (0..=max_shift).rev(){ - result.as_bits_mut().as_bits_mut().set_bit(shift,true); + result.as_bits_mut().set_bit(shift,true); if wide_self](result){ // put it back lol - result.as_bits_mut().as_bits_mut().set_bit(shift,false); + result.as_bits_mut().set_bit(shift,false); } } result @@ -863,4 +868,4 @@ impl_not_const_generic!(4,8); impl_not_const_generic!(5,10); impl_not_const_generic!(6,12); impl_not_const_generic!(7,14); -impl_not_const_generic!(8,16); +impl_not_const_generic!(8,1024); diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 0b3be4d2..5f913f29 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -67,7 +67,7 @@ fn from_f32(){ assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Underflow)); //test many cases for i in 0..64{ - let a=crate::fixed::Fixed::<2,64>::raw_digit(0b111111111111111111111111000000000000000000000000000000000000000i64)<::from_u64(0b111111111111111111111111000000000000000000000000000000000000000u64)<,_>=f.try_into(); assert_eq!(b,Ok(a)); diff --git a/lib/fixed_wide/src/types.rs b/lib/fixed_wide/src/types.rs index 86944354..c170dbf0 100644 --- a/lib/fixed_wide/src/types.rs +++ b/lib/fixed_wide/src/types.rs @@ -1,4 +1,5 @@ -pub type I32F32=crate::fixed::Fixed<1,32>; -pub type I64F64=crate::fixed::Fixed<2,64>; -pub type I128F128=crate::fixed::Fixed<4,128>; -pub type I256F256=crate::fixed::Fixed<8,256>; +pub type I32F32=crate::fixed::Fixed<8,32>; +pub type I64F64=crate::fixed::Fixed<16,64>; +pub type I96F96=crate::fixed::Fixed<24,96>; +pub type I128F128=crate::fixed::Fixed<32,128>; +pub type I256F256=crate::fixed::Fixed<64,256>; -- 2.49.1 From 4e66388d878391586e148eb00a7d47dc380a68f2 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:01:35 -0700 Subject: [PATCH 02/86] n --- lib/fixed_wide/src/fixed.rs | 64 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 6669b5da..19bf3758 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -496,7 +496,7 @@ macro_rules! macro_repeated{ macro_rules! macro_16 { ( $macro: ident, $any:tt ) => { - macro_repeated!($macro,$any,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); + macro_repeated!($macro,$any,1,2,3,4,5,6,7,8,9,10,704,768,832,896,960,1024); } } @@ -658,20 +658,20 @@ macro_rules! impl_wide_same_size_not_const_generic{ //const generics sidestepped wahoo macro_repeated!( impl_wide_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1),(14,1),(960,1), - (1,2), (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(9,2),(10,2),(11,2),(12,2),(13,2),(14,2), - (1,3),(2,3), (4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(10,3),(11,3),(12,3),(13,3), - (1,4),(2,4),(3,4), (5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(11,4),(12,4), - (1,5),(2,5),(3,5),(4,5), (6,5),(7,5),(8,5),(9,5),(10,5),(11,5), + (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(704,1),(768,1),(832,1),(896,1),(960,1), + (1,2), (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(9,2),(10,2),(704,2),(768,2),(832,2),(896,2), + (1,3),(2,3), (4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(10,3),(704,3),(768,3),(832,3), + (1,4),(2,4),(3,4), (5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(704,4),(768,4), + (1,5),(2,5),(3,5),(4,5), (6,5),(7,5),(8,5),(9,5),(10,5),(704,5), (1,6),(2,6),(3,6),(4,6),(5,6), (7,6),(8,6),(9,6),(10,6), (1,7),(2,7),(3,7),(4,7),(5,7),(6,7), (8,7),(9,7), (1,8),(2,8),(3,8),(4,8),(5,8),(6,8),(7,8), (9,8), (1,9),(2,9),(3,9),(4,9),(5,9),(6,9),(7,9), (1,10),(2,10),(3,10),(4,10),(5,10),(6,10), - (1,11),(2,11),(3,11),(4,11),(5,11), - (1,12),(2,12),(3,12),(4,12), - (1,13),(2,13),(3,13), - (1,14),(2,14), + (1,704),(2,704),(3,704),(4,704),(5,704), + (1,768),(2,768),(3,768),(4,768), + (1,832),(2,832),(3,832), + (1,896),(2,896), (1,960) ); macro_repeated!( @@ -777,20 +777,20 @@ macro_rules! impl_widen_not_const_generic{ macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1),(14,1),(960,1),(1024,1),(1088,1), - (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(9,2),(10,2),(11,2),(12,2),(13,2),(14,2),(960,2),(1024,2), - (4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(10,3),(11,3),(12,3),(13,3),(14,3),(960,3),(1024,3), - (5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(11,4),(12,4),(13,4),(14,4),(960,4),(1024,4), - (6,5),(7,5),(8,5),(9,5),(10,5),(11,5),(12,5),(13,5),(14,5),(960,5),(1024,5), - (7,6),(8,6),(9,6),(10,6),(11,6),(12,6),(13,6),(14,6),(960,6),(1024,6), - (8,7),(9,7),(10,7),(11,7),(12,7),(13,7),(14,7),(960,7),(1024,7), - (9,8),(10,8),(11,8),(12,8),(13,8),(14,8),(960,8),(1024,8), - (10,9),(11,9),(12,9),(13,9),(14,9),(960,9),(1024,9), - (11,10),(12,10),(13,10),(14,10),(960,10),(1024,10), - (12,11),(13,11),(14,11),(960,11),(1024,11), - (13,12),(14,12),(960,12),(1024,12), - (14,13),(960,13),(1024,13), - (960,14),(1024,14), + (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(9,2),(10,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(10,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), + (5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), + (6,5),(7,5),(8,5),(9,5),(10,5),(704,5),(768,5),(832,5),(896,5),(960,5),(1024,5), + (7,6),(8,6),(9,6),(10,6),(704,6),(768,6),(832,6),(896,6),(960,6),(1024,6), + (8,7),(9,7),(10,7),(704,7),(768,7),(832,7),(896,7),(960,7),(1024,7), + (9,8),(10,8),(704,8),(768,8),(832,8),(896,8),(960,8),(1024,8), + (10,9),(704,9),(768,9),(832,9),(896,9),(960,9),(1024,9), + (704,10),(768,10),(832,10),(896,10),(960,10),(1024,10), + (768,704),(832,704),(896,704),(960,704),(1024,704), + (832,768),(896,768),(960,768),(1024,768), + (896,832),(960,832),(1024,832), + (960,896),(1024,896), (1024,960) ); macro_repeated!( @@ -804,12 +804,12 @@ macro_repeated!( (1,8),(2,8),(3,8),(4,8),(5,8),(6,8),(7,8), (1,9),(2,9),(3,9),(4,9),(5,9),(6,9),(7,9),(8,9), (1,10),(2,10),(3,10),(4,10),(5,10),(6,10),(7,10),(8,10),(9,10), - (1,11),(2,11),(3,11),(4,11),(5,11),(6,11),(7,11),(8,11),(9,11),(10,11), - (1,12),(2,12),(3,12),(4,12),(5,12),(6,12),(7,12),(8,12),(9,12),(10,12),(11,12), - (1,13),(2,13),(3,13),(4,13),(5,13),(6,13),(7,13),(8,13),(9,13),(10,13),(11,13),(12,13), - (1,14),(2,14),(3,14),(4,14),(5,14),(6,14),(7,14),(8,14),(9,14),(10,14),(11,14),(12,14),(13,14), - (1,960),(2,960),(3,960),(4,960),(5,960),(6,960),(7,960),(8,960),(9,960),(10,960),(11,960),(12,960),(13,960),(14,960), - (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(6,1024),(7,1024),(8,1024),(9,1024),(10,1024),(11,1024),(12,1024),(13,1024),(14,1024),(960,1024), + (1,704),(2,704),(3,704),(4,704),(5,704),(6,704),(7,704),(8,704),(9,704),(10,704), + (1,768),(2,768),(3,768),(4,768),(5,768),(6,768),(7,768),(8,768),(9,768),(10,768),(704,768), + (1,832),(2,832),(3,832),(4,832),(5,832),(6,832),(7,832),(8,832),(9,832),(10,832),(704,832),(768,832), + (1,896),(2,896),(3,896),(4,896),(5,896),(6,896),(7,896),(8,896),(9,896),(10,896),(704,896),(768,896),(832,896), + (1,960),(2,960),(3,960),(4,960),(5,960),(6,960),(7,960),(8,960),(9,960),(10,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(6,1024),(7,1024),(8,1024),(9,1024),(10,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), (1,1088) ); @@ -866,6 +866,6 @@ impl_not_const_generic!(2,4); impl_not_const_generic!(3,6); impl_not_const_generic!(4,8); impl_not_const_generic!(5,10); -impl_not_const_generic!(6,12); -impl_not_const_generic!(7,14); +impl_not_const_generic!(6,768); +impl_not_const_generic!(7,896); impl_not_const_generic!(8,1024); -- 2.49.1 From 8e955bd7e6bc957532a9a84d21dd792e519c4d63 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:03:45 -0700 Subject: [PATCH 03/86] n --- lib/fixed_wide/src/fixed.rs | 60 ++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 19bf3758..1b6c4f31 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -496,7 +496,7 @@ macro_rules! macro_repeated{ macro_rules! macro_16 { ( $macro: ident, $any:tt ) => { - macro_repeated!($macro,$any,1,2,3,4,5,6,7,8,9,10,704,768,832,896,960,1024); + macro_repeated!($macro,$any,1,2,3,4,5,6,7,8,576,640,704,768,832,896,960,1024); } } @@ -658,16 +658,16 @@ macro_rules! impl_wide_same_size_not_const_generic{ //const generics sidestepped wahoo macro_repeated!( impl_wide_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(704,1),(768,1),(832,1),(896,1),(960,1), - (1,2), (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(9,2),(10,2),(704,2),(768,2),(832,2),(896,2), - (1,3),(2,3), (4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(10,3),(704,3),(768,3),(832,3), - (1,4),(2,4),(3,4), (5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(704,4),(768,4), - (1,5),(2,5),(3,5),(4,5), (6,5),(7,5),(8,5),(9,5),(10,5),(704,5), - (1,6),(2,6),(3,6),(4,6),(5,6), (7,6),(8,6),(9,6),(10,6), - (1,7),(2,7),(3,7),(4,7),(5,7),(6,7), (8,7),(9,7), - (1,8),(2,8),(3,8),(4,8),(5,8),(6,8),(7,8), (9,8), - (1,9),(2,9),(3,9),(4,9),(5,9),(6,9),(7,9), - (1,10),(2,10),(3,10),(4,10),(5,10),(6,10), + (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), + (1,2), (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), + (1,3),(2,3), (4,3),(5,3),(6,3),(7,3),(8,3),(576,3),(640,3),(704,3),(768,3),(832,3), + (1,4),(2,4),(3,4), (5,4),(6,4),(7,4),(8,4),(576,4),(640,4),(704,4),(768,4), + (1,5),(2,5),(3,5),(4,5), (6,5),(7,5),(8,5),(576,5),(640,5),(704,5), + (1,6),(2,6),(3,6),(4,6),(5,6), (7,6),(8,6),(576,6),(640,6), + (1,7),(2,7),(3,7),(4,7),(5,7),(6,7), (8,7),(576,7), + (1,8),(2,8),(3,8),(4,8),(5,8),(6,8),(7,8), (576,8), + (1,576),(2,576),(3,576),(4,576),(5,576),(6,576),(7,576), + (1,640),(2,640),(3,640),(4,640),(5,640),(6,640), (1,704),(2,704),(3,704),(4,704),(5,704), (1,768),(2,768),(3,768),(4,768), (1,832),(2,832),(3,832), @@ -777,16 +777,16 @@ macro_rules! impl_widen_not_const_generic{ macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), - (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(9,2),(10,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), - (4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(10,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), - (5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), - (6,5),(7,5),(8,5),(9,5),(10,5),(704,5),(768,5),(832,5),(896,5),(960,5),(1024,5), - (7,6),(8,6),(9,6),(10,6),(704,6),(768,6),(832,6),(896,6),(960,6),(1024,6), - (8,7),(9,7),(10,7),(704,7),(768,7),(832,7),(896,7),(960,7),(1024,7), - (9,8),(10,8),(704,8),(768,8),(832,8),(896,8),(960,8),(1024,8), - (10,9),(704,9),(768,9),(832,9),(896,9),(960,9),(1024,9), - (704,10),(768,10),(832,10),(896,10),(960,10),(1024,10), + (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (4,3),(5,3),(6,3),(7,3),(8,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), + (5,4),(6,4),(7,4),(8,4),(576,4),(640,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), + (6,5),(7,5),(8,5),(576,5),(640,5),(704,5),(768,5),(832,5),(896,5),(960,5),(1024,5), + (7,6),(8,6),(576,6),(640,6),(704,6),(768,6),(832,6),(896,6),(960,6),(1024,6), + (8,7),(576,7),(640,7),(704,7),(768,7),(832,7),(896,7),(960,7),(1024,7), + (576,8),(640,8),(704,8),(768,8),(832,8),(896,8),(960,8),(1024,8), + (640,576),(704,576),(768,576),(832,576),(896,576),(960,576),(1024,576), + (704,640),(768,640),(832,640),(896,640),(960,640),(1024,640), (768,704),(832,704),(896,704),(960,704),(1024,704), (832,768),(896,768),(960,768),(1024,768), (896,832),(960,832),(1024,832), @@ -802,14 +802,14 @@ macro_repeated!( (1,6),(2,6),(3,6),(4,6),(5,6), (1,7),(2,7),(3,7),(4,7),(5,7),(6,7), (1,8),(2,8),(3,8),(4,8),(5,8),(6,8),(7,8), - (1,9),(2,9),(3,9),(4,9),(5,9),(6,9),(7,9),(8,9), - (1,10),(2,10),(3,10),(4,10),(5,10),(6,10),(7,10),(8,10),(9,10), - (1,704),(2,704),(3,704),(4,704),(5,704),(6,704),(7,704),(8,704),(9,704),(10,704), - (1,768),(2,768),(3,768),(4,768),(5,768),(6,768),(7,768),(8,768),(9,768),(10,768),(704,768), - (1,832),(2,832),(3,832),(4,832),(5,832),(6,832),(7,832),(8,832),(9,832),(10,832),(704,832),(768,832), - (1,896),(2,896),(3,896),(4,896),(5,896),(6,896),(7,896),(8,896),(9,896),(10,896),(704,896),(768,896),(832,896), - (1,960),(2,960),(3,960),(4,960),(5,960),(6,960),(7,960),(8,960),(9,960),(10,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(6,1024),(7,1024),(8,1024),(9,1024),(10,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (1,576),(2,576),(3,576),(4,576),(5,576),(6,576),(7,576),(8,576), + (1,640),(2,640),(3,640),(4,640),(5,640),(6,640),(7,640),(8,640),(576,640), + (1,704),(2,704),(3,704),(4,704),(5,704),(6,704),(7,704),(8,704),(576,704),(640,704), + (1,768),(2,768),(3,768),(4,768),(5,768),(6,768),(7,768),(8,768),(576,768),(640,768),(704,768), + (1,832),(2,832),(3,832),(4,832),(5,832),(6,832),(7,832),(8,832),(576,832),(640,832),(704,832),(768,832), + (1,896),(2,896),(3,896),(4,896),(5,896),(6,896),(7,896),(8,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (1,960),(2,960),(3,960),(4,960),(5,960),(6,960),(7,960),(8,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(6,1024),(7,1024),(8,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), (1,1088) ); @@ -865,7 +865,7 @@ impl_not_const_generic!(1,2); impl_not_const_generic!(2,4); impl_not_const_generic!(3,6); impl_not_const_generic!(4,8); -impl_not_const_generic!(5,10); +impl_not_const_generic!(5,640); impl_not_const_generic!(6,768); impl_not_const_generic!(7,896); impl_not_const_generic!(8,1024); -- 2.49.1 From 13d57dbd144dc7d4f6fd521d40dbfa39171faaa8 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:05:17 -0700 Subject: [PATCH 04/86] 8 --- lib/fixed_wide/src/fixed.rs | 58 ++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 1b6c4f31..5777260e 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -496,7 +496,7 @@ macro_rules! macro_repeated{ macro_rules! macro_16 { ( $macro: ident, $any:tt ) => { - macro_repeated!($macro,$any,1,2,3,4,5,6,7,8,576,640,704,768,832,896,960,1024); + macro_repeated!($macro,$any,1,2,3,4,5,6,7,512,576,640,704,768,832,896,960,1024); } } @@ -658,14 +658,14 @@ macro_rules! impl_wide_same_size_not_const_generic{ //const generics sidestepped wahoo macro_repeated!( impl_wide_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), - (1,2), (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), - (1,3),(2,3), (4,3),(5,3),(6,3),(7,3),(8,3),(576,3),(640,3),(704,3),(768,3),(832,3), - (1,4),(2,4),(3,4), (5,4),(6,4),(7,4),(8,4),(576,4),(640,4),(704,4),(768,4), - (1,5),(2,5),(3,5),(4,5), (6,5),(7,5),(8,5),(576,5),(640,5),(704,5), - (1,6),(2,6),(3,6),(4,6),(5,6), (7,6),(8,6),(576,6),(640,6), - (1,7),(2,7),(3,7),(4,7),(5,7),(6,7), (8,7),(576,7), - (1,8),(2,8),(3,8),(4,8),(5,8),(6,8),(7,8), (576,8), + (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), + (1,2), (3,2),(4,2),(5,2),(6,2),(7,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), + (1,3),(2,3), (4,3),(5,3),(6,3),(7,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3), + (1,4),(2,4),(3,4), (5,4),(6,4),(7,4),(512,4),(576,4),(640,4),(704,4),(768,4), + (1,5),(2,5),(3,5),(4,5), (6,5),(7,5),(512,5),(576,5),(640,5),(704,5), + (1,6),(2,6),(3,6),(4,6),(5,6), (7,6),(512,6),(576,6),(640,6), + (1,7),(2,7),(3,7),(4,7),(5,7),(6,7), (512,7),(576,7), + (1,512),(2,512),(3,512),(4,512),(5,512),(6,512),(7,512), (576,512), (1,576),(2,576),(3,576),(4,576),(5,576),(6,576),(7,576), (1,640),(2,640),(3,640),(4,640),(5,640),(6,640), (1,704),(2,704),(3,704),(4,704),(5,704), @@ -676,7 +676,7 @@ macro_repeated!( ); macro_repeated!( impl_wide_same_size_not_const_generic,(), - 1,2,3,4,5,6,7,8 + 1,2,3,4,5,6,7,512 ); #[derive(Debug,Eq,PartialEq)] @@ -777,14 +777,14 @@ macro_rules! impl_widen_not_const_generic{ macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), - (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), - (4,3),(5,3),(6,3),(7,3),(8,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), - (5,4),(6,4),(7,4),(8,4),(576,4),(640,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), - (6,5),(7,5),(8,5),(576,5),(640,5),(704,5),(768,5),(832,5),(896,5),(960,5),(1024,5), - (7,6),(8,6),(576,6),(640,6),(704,6),(768,6),(832,6),(896,6),(960,6),(1024,6), - (8,7),(576,7),(640,7),(704,7),(768,7),(832,7),(896,7),(960,7),(1024,7), - (576,8),(640,8),(704,8),(768,8),(832,8),(896,8),(960,8),(1024,8), + (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (3,2),(4,2),(5,2),(6,2),(7,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (4,3),(5,3),(6,3),(7,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), + (5,4),(6,4),(7,4),(512,4),(576,4),(640,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), + (6,5),(7,5),(512,5),(576,5),(640,5),(704,5),(768,5),(832,5),(896,5),(960,5),(1024,5), + (7,6),(512,6),(576,6),(640,6),(704,6),(768,6),(832,6),(896,6),(960,6),(1024,6), + (512,7),(576,7),(640,7),(704,7),(768,7),(832,7),(896,7),(960,7),(1024,7), + (576,512),(640,512),(704,512),(768,512),(832,512),(896,512),(960,512),(1024,512), (640,576),(704,576),(768,576),(832,576),(896,576),(960,576),(1024,576), (704,640),(768,640),(832,640),(896,640),(960,640),(1024,640), (768,704),(832,704),(896,704),(960,704),(1024,704), @@ -801,15 +801,15 @@ macro_repeated!( (1,5),(2,5),(3,5),(4,5), (1,6),(2,6),(3,6),(4,6),(5,6), (1,7),(2,7),(3,7),(4,7),(5,7),(6,7), - (1,8),(2,8),(3,8),(4,8),(5,8),(6,8),(7,8), - (1,576),(2,576),(3,576),(4,576),(5,576),(6,576),(7,576),(8,576), - (1,640),(2,640),(3,640),(4,640),(5,640),(6,640),(7,640),(8,640),(576,640), - (1,704),(2,704),(3,704),(4,704),(5,704),(6,704),(7,704),(8,704),(576,704),(640,704), - (1,768),(2,768),(3,768),(4,768),(5,768),(6,768),(7,768),(8,768),(576,768),(640,768),(704,768), - (1,832),(2,832),(3,832),(4,832),(5,832),(6,832),(7,832),(8,832),(576,832),(640,832),(704,832),(768,832), - (1,896),(2,896),(3,896),(4,896),(5,896),(6,896),(7,896),(8,896),(576,896),(640,896),(704,896),(768,896),(832,896), - (1,960),(2,960),(3,960),(4,960),(5,960),(6,960),(7,960),(8,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(6,1024),(7,1024),(8,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (1,512),(2,512),(3,512),(4,512),(5,512),(6,512),(7,512), + (1,576),(2,576),(3,576),(4,576),(5,576),(6,576),(7,576),(512,576), + (1,640),(2,640),(3,640),(4,640),(5,640),(6,640),(7,640),(512,640),(576,640), + (1,704),(2,704),(3,704),(4,704),(5,704),(6,704),(7,704),(512,704),(576,704),(640,704), + (1,768),(2,768),(3,768),(4,768),(5,768),(6,768),(7,768),(512,768),(576,768),(640,768),(704,768), + (1,832),(2,832),(3,832),(4,832),(5,832),(6,832),(7,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (1,896),(2,896),(3,896),(4,896),(5,896),(6,896),(7,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (1,960),(2,960),(3,960),(4,960),(5,960),(6,960),(7,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(6,1024),(7,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), (1,1088) ); @@ -864,8 +864,8 @@ macro_rules! impl_not_const_generic{ impl_not_const_generic!(1,2); impl_not_const_generic!(2,4); impl_not_const_generic!(3,6); -impl_not_const_generic!(4,8); +impl_not_const_generic!(4,512); impl_not_const_generic!(5,640); impl_not_const_generic!(6,768); impl_not_const_generic!(7,896); -impl_not_const_generic!(8,1024); +impl_not_const_generic!(512,1024); -- 2.49.1 From d3e918a1983652fdc175d164a3b12cb313adf451 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:05:35 -0700 Subject: [PATCH 05/86] 7 --- lib/fixed_wide/src/fixed.rs | 58 ++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 5777260e..175e2619 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -496,7 +496,7 @@ macro_rules! macro_repeated{ macro_rules! macro_16 { ( $macro: ident, $any:tt ) => { - macro_repeated!($macro,$any,1,2,3,4,5,6,7,512,576,640,704,768,832,896,960,1024); + macro_repeated!($macro,$any,1,2,3,4,5,6,448,512,576,640,704,768,832,896,960,1024); } } @@ -658,15 +658,15 @@ macro_rules! impl_wide_same_size_not_const_generic{ //const generics sidestepped wahoo macro_repeated!( impl_wide_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), - (1,2), (3,2),(4,2),(5,2),(6,2),(7,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), - (1,3),(2,3), (4,3),(5,3),(6,3),(7,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3), - (1,4),(2,4),(3,4), (5,4),(6,4),(7,4),(512,4),(576,4),(640,4),(704,4),(768,4), - (1,5),(2,5),(3,5),(4,5), (6,5),(7,5),(512,5),(576,5),(640,5),(704,5), - (1,6),(2,6),(3,6),(4,6),(5,6), (7,6),(512,6),(576,6),(640,6), - (1,7),(2,7),(3,7),(4,7),(5,7),(6,7), (512,7),(576,7), - (1,512),(2,512),(3,512),(4,512),(5,512),(6,512),(7,512), (576,512), - (1,576),(2,576),(3,576),(4,576),(5,576),(6,576),(7,576), + (2,1),(3,1),(4,1),(5,1),(6,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), + (1,2), (3,2),(4,2),(5,2),(6,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), + (1,3),(2,3), (4,3),(5,3),(6,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3), + (1,4),(2,4),(3,4), (5,4),(6,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4), + (1,5),(2,5),(3,5),(4,5), (6,5),(448,5),(512,5),(576,5),(640,5),(704,5), + (1,6),(2,6),(3,6),(4,6),(5,6), (448,6),(512,6),(576,6),(640,6), + (1,448),(2,448),(3,448),(4,448),(5,448),(6,448), (512,448),(576,448), + (1,512),(2,512),(3,512),(4,512),(5,512),(6,512),(448,512), (576,512), + (1,576),(2,576),(3,576),(4,576),(5,576),(6,576),(448,576), (1,640),(2,640),(3,640),(4,640),(5,640),(6,640), (1,704),(2,704),(3,704),(4,704),(5,704), (1,768),(2,768),(3,768),(4,768), @@ -676,7 +676,7 @@ macro_repeated!( ); macro_repeated!( impl_wide_same_size_not_const_generic,(), - 1,2,3,4,5,6,7,512 + 1,2,3,4,5,6,448,512 ); #[derive(Debug,Eq,PartialEq)] @@ -777,13 +777,13 @@ macro_rules! impl_widen_not_const_generic{ macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), - (3,2),(4,2),(5,2),(6,2),(7,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), - (4,3),(5,3),(6,3),(7,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), - (5,4),(6,4),(7,4),(512,4),(576,4),(640,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), - (6,5),(7,5),(512,5),(576,5),(640,5),(704,5),(768,5),(832,5),(896,5),(960,5),(1024,5), - (7,6),(512,6),(576,6),(640,6),(704,6),(768,6),(832,6),(896,6),(960,6),(1024,6), - (512,7),(576,7),(640,7),(704,7),(768,7),(832,7),(896,7),(960,7),(1024,7), + (2,1),(3,1),(4,1),(5,1),(6,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (3,2),(4,2),(5,2),(6,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (4,3),(5,3),(6,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), + (5,4),(6,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), + (6,5),(448,5),(512,5),(576,5),(640,5),(704,5),(768,5),(832,5),(896,5),(960,5),(1024,5), + (448,6),(512,6),(576,6),(640,6),(704,6),(768,6),(832,6),(896,6),(960,6),(1024,6), + (512,448),(576,448),(640,448),(704,448),(768,448),(832,448),(896,448),(960,448),(1024,448), (576,512),(640,512),(704,512),(768,512),(832,512),(896,512),(960,512),(1024,512), (640,576),(704,576),(768,576),(832,576),(896,576),(960,576),(1024,576), (704,640),(768,640),(832,640),(896,640),(960,640),(1024,640), @@ -800,16 +800,16 @@ macro_repeated!( (1,4),(2,4),(3,4), (1,5),(2,5),(3,5),(4,5), (1,6),(2,6),(3,6),(4,6),(5,6), - (1,7),(2,7),(3,7),(4,7),(5,7),(6,7), - (1,512),(2,512),(3,512),(4,512),(5,512),(6,512),(7,512), - (1,576),(2,576),(3,576),(4,576),(5,576),(6,576),(7,576),(512,576), - (1,640),(2,640),(3,640),(4,640),(5,640),(6,640),(7,640),(512,640),(576,640), - (1,704),(2,704),(3,704),(4,704),(5,704),(6,704),(7,704),(512,704),(576,704),(640,704), - (1,768),(2,768),(3,768),(4,768),(5,768),(6,768),(7,768),(512,768),(576,768),(640,768),(704,768), - (1,832),(2,832),(3,832),(4,832),(5,832),(6,832),(7,832),(512,832),(576,832),(640,832),(704,832),(768,832), - (1,896),(2,896),(3,896),(4,896),(5,896),(6,896),(7,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), - (1,960),(2,960),(3,960),(4,960),(5,960),(6,960),(7,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(6,1024),(7,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (1,448),(2,448),(3,448),(4,448),(5,448),(6,448), + (1,512),(2,512),(3,512),(4,512),(5,512),(6,512),(448,512), + (1,576),(2,576),(3,576),(4,576),(5,576),(6,576),(448,576),(512,576), + (1,640),(2,640),(3,640),(4,640),(5,640),(6,640),(448,640),(512,640),(576,640), + (1,704),(2,704),(3,704),(4,704),(5,704),(6,704),(448,704),(512,704),(576,704),(640,704), + (1,768),(2,768),(3,768),(4,768),(5,768),(6,768),(448,768),(512,768),(576,768),(640,768),(704,768), + (1,832),(2,832),(3,832),(4,832),(5,832),(6,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (1,896),(2,896),(3,896),(4,896),(5,896),(6,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (1,960),(2,960),(3,960),(4,960),(5,960),(6,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(6,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), (1,1088) ); @@ -867,5 +867,5 @@ impl_not_const_generic!(3,6); impl_not_const_generic!(4,512); impl_not_const_generic!(5,640); impl_not_const_generic!(6,768); -impl_not_const_generic!(7,896); +impl_not_const_generic!(448,896); impl_not_const_generic!(512,1024); -- 2.49.1 From e38831ccee5bc77fd4f017f39e7f613da0c740e7 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:08:07 -0700 Subject: [PATCH 06/86] 6 --- lib/fixed_wide/src/fixed.rs | 62 ++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 175e2619..8abf8e37 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -496,7 +496,7 @@ macro_rules! macro_repeated{ macro_rules! macro_16 { ( $macro: ident, $any:tt ) => { - macro_repeated!($macro,$any,1,2,3,4,5,6,448,512,576,640,704,768,832,896,960,1024); + macro_repeated!($macro,$any,1,2,3,4,5,384,448,512,576,640,704,768,832,896,960,1024); } } @@ -658,16 +658,16 @@ macro_rules! impl_wide_same_size_not_const_generic{ //const generics sidestepped wahoo macro_repeated!( impl_wide_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), - (1,2), (3,2),(4,2),(5,2),(6,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), - (1,3),(2,3), (4,3),(5,3),(6,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3), - (1,4),(2,4),(3,4), (5,4),(6,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4), - (1,5),(2,5),(3,5),(4,5), (6,5),(448,5),(512,5),(576,5),(640,5),(704,5), - (1,6),(2,6),(3,6),(4,6),(5,6), (448,6),(512,6),(576,6),(640,6), - (1,448),(2,448),(3,448),(4,448),(5,448),(6,448), (512,448),(576,448), - (1,512),(2,512),(3,512),(4,512),(5,512),(6,512),(448,512), (576,512), - (1,576),(2,576),(3,576),(4,576),(5,576),(6,576),(448,576), - (1,640),(2,640),(3,640),(4,640),(5,640),(6,640), + (2,1),(3,1),(4,1),(5,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), + (1,2), (3,2),(4,2),(5,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), + (1,3),(2,3), (4,3),(5,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3), + (1,4),(2,4),(3,4), (5,4),(384,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4), + (1,5),(2,5),(3,5),(4,5), (384,5),(448,5),(512,5),(576,5),(640,5),(704,5), + (1,384),(2,384),(3,384),(4,384),(5,384), (448,384),(512,384),(576,384),(640,384), + (1,448),(2,448),(3,448),(4,448),(5,448),(384,448), (512,448),(576,448), + (1,512),(2,512),(3,512),(4,512),(5,512),(384,512),(448,512), (576,512), + (1,576),(2,576),(3,576),(4,576),(5,576),(384,576),(448,576), + (1,640),(2,640),(3,640),(4,640),(5,640),(384,640), (1,704),(2,704),(3,704),(4,704),(5,704), (1,768),(2,768),(3,768),(4,768), (1,832),(2,832),(3,832), @@ -676,7 +676,7 @@ macro_repeated!( ); macro_repeated!( impl_wide_same_size_not_const_generic,(), - 1,2,3,4,5,6,448,512 + 1,2,3,4,5,384,448,512 ); #[derive(Debug,Eq,PartialEq)] @@ -777,12 +777,12 @@ macro_rules! impl_widen_not_const_generic{ macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), - (3,2),(4,2),(5,2),(6,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), - (4,3),(5,3),(6,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), - (5,4),(6,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), - (6,5),(448,5),(512,5),(576,5),(640,5),(704,5),(768,5),(832,5),(896,5),(960,5),(1024,5), - (448,6),(512,6),(576,6),(640,6),(704,6),(768,6),(832,6),(896,6),(960,6),(1024,6), + (2,1),(3,1),(4,1),(5,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (3,2),(4,2),(5,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (4,3),(5,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), + (5,4),(384,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), + (384,5),(448,5),(512,5),(576,5),(640,5),(704,5),(768,5),(832,5),(896,5),(960,5),(1024,5), + (448,384),(512,384),(576,384),(640,384),(704,384),(768,384),(832,384),(896,384),(960,384),(1024,384), (512,448),(576,448),(640,448),(704,448),(768,448),(832,448),(896,448),(960,448),(1024,448), (576,512),(640,512),(704,512),(768,512),(832,512),(896,512),(960,512),(1024,512), (640,576),(704,576),(768,576),(832,576),(896,576),(960,576),(1024,576), @@ -799,17 +799,17 @@ macro_repeated!( (1,3),(2,3), (1,4),(2,4),(3,4), (1,5),(2,5),(3,5),(4,5), - (1,6),(2,6),(3,6),(4,6),(5,6), - (1,448),(2,448),(3,448),(4,448),(5,448),(6,448), - (1,512),(2,512),(3,512),(4,512),(5,512),(6,512),(448,512), - (1,576),(2,576),(3,576),(4,576),(5,576),(6,576),(448,576),(512,576), - (1,640),(2,640),(3,640),(4,640),(5,640),(6,640),(448,640),(512,640),(576,640), - (1,704),(2,704),(3,704),(4,704),(5,704),(6,704),(448,704),(512,704),(576,704),(640,704), - (1,768),(2,768),(3,768),(4,768),(5,768),(6,768),(448,768),(512,768),(576,768),(640,768),(704,768), - (1,832),(2,832),(3,832),(4,832),(5,832),(6,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), - (1,896),(2,896),(3,896),(4,896),(5,896),(6,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), - (1,960),(2,960),(3,960),(4,960),(5,960),(6,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(6,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (1,384),(2,384),(3,384),(4,384),(5,384), + (1,448),(2,448),(3,448),(4,448),(5,448),(384,448), + (1,512),(2,512),(3,512),(4,512),(5,512),(384,512),(448,512), + (1,576),(2,576),(3,576),(4,576),(5,576),(384,576),(448,576),(512,576), + (1,640),(2,640),(3,640),(4,640),(5,640),(384,640),(448,640),(512,640),(576,640), + (1,704),(2,704),(3,704),(4,704),(5,704),(384,704),(448,704),(512,704),(576,704),(640,704), + (1,768),(2,768),(3,768),(4,768),(5,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), + (1,832),(2,832),(3,832),(4,832),(5,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (1,896),(2,896),(3,896),(4,896),(5,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (1,960),(2,960),(3,960),(4,960),(5,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), (1,1088) ); @@ -863,9 +863,9 @@ macro_rules! impl_not_const_generic{ } impl_not_const_generic!(1,2); impl_not_const_generic!(2,4); -impl_not_const_generic!(3,6); +impl_not_const_generic!(3,384); impl_not_const_generic!(4,512); impl_not_const_generic!(5,640); -impl_not_const_generic!(6,768); +impl_not_const_generic!(384,768); impl_not_const_generic!(448,896); impl_not_const_generic!(512,1024); -- 2.49.1 From 85f3e0fb6600c08a794b5f149eea1115ab489e3e Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:08:28 -0700 Subject: [PATCH 07/86] 5 --- lib/fixed_wide/src/fixed.rs | 62 ++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 8abf8e37..84785934 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -496,7 +496,7 @@ macro_rules! macro_repeated{ macro_rules! macro_16 { ( $macro: ident, $any:tt ) => { - macro_repeated!($macro,$any,1,2,3,4,5,384,448,512,576,640,704,768,832,896,960,1024); + macro_repeated!($macro,$any,1,2,3,4,320,384,448,512,576,640,704,768,832,896,960,1024); } } @@ -658,17 +658,17 @@ macro_rules! impl_wide_same_size_not_const_generic{ //const generics sidestepped wahoo macro_repeated!( impl_wide_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), - (1,2), (3,2),(4,2),(5,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), - (1,3),(2,3), (4,3),(5,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3), - (1,4),(2,4),(3,4), (5,4),(384,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4), - (1,5),(2,5),(3,5),(4,5), (384,5),(448,5),(512,5),(576,5),(640,5),(704,5), - (1,384),(2,384),(3,384),(4,384),(5,384), (448,384),(512,384),(576,384),(640,384), - (1,448),(2,448),(3,448),(4,448),(5,448),(384,448), (512,448),(576,448), - (1,512),(2,512),(3,512),(4,512),(5,512),(384,512),(448,512), (576,512), - (1,576),(2,576),(3,576),(4,576),(5,576),(384,576),(448,576), - (1,640),(2,640),(3,640),(4,640),(5,640),(384,640), - (1,704),(2,704),(3,704),(4,704),(5,704), + (2,1),(3,1),(4,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), + (1,2), (3,2),(4,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), + (1,3),(2,3), (4,3),(320,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3), + (1,4),(2,4),(3,4), (320,4),(384,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4), + (1,320),(2,320),(3,320),(4,320), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320), + (1,384),(2,384),(3,384),(4,384),(320,384), (448,384),(512,384),(576,384),(640,384), + (1,448),(2,448),(3,448),(4,448),(320,448),(384,448), (512,448),(576,448), + (1,512),(2,512),(3,512),(4,512),(320,512),(384,512),(448,512), (576,512), + (1,576),(2,576),(3,576),(4,576),(320,576),(384,576),(448,576), + (1,640),(2,640),(3,640),(4,640),(320,640),(384,640), + (1,704),(2,704),(3,704),(4,704),(320,704), (1,768),(2,768),(3,768),(4,768), (1,832),(2,832),(3,832), (1,896),(2,896), @@ -676,7 +676,7 @@ macro_repeated!( ); macro_repeated!( impl_wide_same_size_not_const_generic,(), - 1,2,3,4,5,384,448,512 + 1,2,3,4,320,384,448,512 ); #[derive(Debug,Eq,PartialEq)] @@ -777,11 +777,11 @@ macro_rules! impl_widen_not_const_generic{ macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), - (3,2),(4,2),(5,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), - (4,3),(5,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), - (5,4),(384,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), - (384,5),(448,5),(512,5),(576,5),(640,5),(704,5),(768,5),(832,5),(896,5),(960,5),(1024,5), + (2,1),(3,1),(4,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (3,2),(4,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (4,3),(320,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), + (320,4),(384,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), + (384,320),(448,320),(512,320),(576,320),(640,320),(704,320),(768,320),(832,320),(896,320),(960,320),(1024,320), (448,384),(512,384),(576,384),(640,384),(704,384),(768,384),(832,384),(896,384),(960,384),(1024,384), (512,448),(576,448),(640,448),(704,448),(768,448),(832,448),(896,448),(960,448),(1024,448), (576,512),(640,512),(704,512),(768,512),(832,512),(896,512),(960,512),(1024,512), @@ -798,18 +798,18 @@ macro_repeated!( (1,2), (1,3),(2,3), (1,4),(2,4),(3,4), - (1,5),(2,5),(3,5),(4,5), - (1,384),(2,384),(3,384),(4,384),(5,384), - (1,448),(2,448),(3,448),(4,448),(5,448),(384,448), - (1,512),(2,512),(3,512),(4,512),(5,512),(384,512),(448,512), - (1,576),(2,576),(3,576),(4,576),(5,576),(384,576),(448,576),(512,576), - (1,640),(2,640),(3,640),(4,640),(5,640),(384,640),(448,640),(512,640),(576,640), - (1,704),(2,704),(3,704),(4,704),(5,704),(384,704),(448,704),(512,704),(576,704),(640,704), - (1,768),(2,768),(3,768),(4,768),(5,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), - (1,832),(2,832),(3,832),(4,832),(5,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), - (1,896),(2,896),(3,896),(4,896),(5,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), - (1,960),(2,960),(3,960),(4,960),(5,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(2,1024),(3,1024),(4,1024),(5,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (1,320),(2,320),(3,320),(4,320), + (1,384),(2,384),(3,384),(4,384),(320,384), + (1,448),(2,448),(3,448),(4,448),(320,448),(384,448), + (1,512),(2,512),(3,512),(4,512),(320,512),(384,512),(448,512), + (1,576),(2,576),(3,576),(4,576),(320,576),(384,576),(448,576),(512,576), + (1,640),(2,640),(3,640),(4,640),(320,640),(384,640),(448,640),(512,640),(576,640), + (1,704),(2,704),(3,704),(4,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), + (1,768),(2,768),(3,768),(4,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), + (1,832),(2,832),(3,832),(4,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (1,896),(2,896),(3,896),(4,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (1,960),(2,960),(3,960),(4,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(2,1024),(3,1024),(4,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), (1,1088) ); @@ -865,7 +865,7 @@ impl_not_const_generic!(1,2); impl_not_const_generic!(2,4); impl_not_const_generic!(3,384); impl_not_const_generic!(4,512); -impl_not_const_generic!(5,640); +impl_not_const_generic!(320,640); impl_not_const_generic!(384,768); impl_not_const_generic!(448,896); impl_not_const_generic!(512,1024); -- 2.49.1 From 295d277379913bcab1a7c2d73aa3c2eb4b644eb6 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:08:43 -0700 Subject: [PATCH 08/86] 4 --- lib/fixed_wide/src/fixed.rs | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 84785934..e99cfd88 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -496,7 +496,7 @@ macro_rules! macro_repeated{ macro_rules! macro_16 { ( $macro: ident, $any:tt ) => { - macro_repeated!($macro,$any,1,2,3,4,320,384,448,512,576,640,704,768,832,896,960,1024); + macro_repeated!($macro,$any,1,2,3,256,320,384,448,512,576,640,704,768,832,896,960,1024); } } @@ -658,25 +658,25 @@ macro_rules! impl_wide_same_size_not_const_generic{ //const generics sidestepped wahoo macro_repeated!( impl_wide_not_const_generic,(), - (2,1),(3,1),(4,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), - (1,2), (3,2),(4,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), - (1,3),(2,3), (4,3),(320,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3), - (1,4),(2,4),(3,4), (320,4),(384,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4), - (1,320),(2,320),(3,320),(4,320), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320), - (1,384),(2,384),(3,384),(4,384),(320,384), (448,384),(512,384),(576,384),(640,384), - (1,448),(2,448),(3,448),(4,448),(320,448),(384,448), (512,448),(576,448), - (1,512),(2,512),(3,512),(4,512),(320,512),(384,512),(448,512), (576,512), - (1,576),(2,576),(3,576),(4,576),(320,576),(384,576),(448,576), - (1,640),(2,640),(3,640),(4,640),(320,640),(384,640), - (1,704),(2,704),(3,704),(4,704),(320,704), - (1,768),(2,768),(3,768),(4,768), + (2,1),(3,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), + (1,2), (3,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), + (1,3),(2,3), (256,3),(320,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3), + (1,256),(2,256),(3,256), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256), + (1,320),(2,320),(3,320),(256,320), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320), + (1,384),(2,384),(3,384),(256,384),(320,384), (448,384),(512,384),(576,384),(640,384), + (1,448),(2,448),(3,448),(256,448),(320,448),(384,448), (512,448),(576,448), + (1,512),(2,512),(3,512),(256,512),(320,512),(384,512),(448,512), (576,512), + (1,576),(2,576),(3,576),(256,576),(320,576),(384,576),(448,576), + (1,640),(2,640),(3,640),(256,640),(320,640),(384,640), + (1,704),(2,704),(3,704),(256,704),(320,704), + (1,768),(2,768),(3,768),(256,768), (1,832),(2,832),(3,832), (1,896),(2,896), (1,960) ); macro_repeated!( impl_wide_same_size_not_const_generic,(), - 1,2,3,4,320,384,448,512 + 1,2,3,256,320,384,448,512 ); #[derive(Debug,Eq,PartialEq)] @@ -777,10 +777,10 @@ macro_rules! impl_widen_not_const_generic{ macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(3,1),(4,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), - (3,2),(4,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), - (4,3),(320,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), - (320,4),(384,4),(448,4),(512,4),(576,4),(640,4),(704,4),(768,4),(832,4),(896,4),(960,4),(1024,4), + (2,1),(3,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (3,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (256,3),(320,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), + (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256),(832,256),(896,256),(960,256),(1024,256), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320),(768,320),(832,320),(896,320),(960,320),(1024,320), (448,384),(512,384),(576,384),(640,384),(704,384),(768,384),(832,384),(896,384),(960,384),(1024,384), (512,448),(576,448),(640,448),(704,448),(768,448),(832,448),(896,448),(960,448),(1024,448), @@ -797,19 +797,19 @@ macro_repeated!( impl_widen_not_const_generic,(), (1,2), (1,3),(2,3), - (1,4),(2,4),(3,4), - (1,320),(2,320),(3,320),(4,320), - (1,384),(2,384),(3,384),(4,384),(320,384), - (1,448),(2,448),(3,448),(4,448),(320,448),(384,448), - (1,512),(2,512),(3,512),(4,512),(320,512),(384,512),(448,512), - (1,576),(2,576),(3,576),(4,576),(320,576),(384,576),(448,576),(512,576), - (1,640),(2,640),(3,640),(4,640),(320,640),(384,640),(448,640),(512,640),(576,640), - (1,704),(2,704),(3,704),(4,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), - (1,768),(2,768),(3,768),(4,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), - (1,832),(2,832),(3,832),(4,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), - (1,896),(2,896),(3,896),(4,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), - (1,960),(2,960),(3,960),(4,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(2,1024),(3,1024),(4,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (1,256),(2,256),(3,256), + (1,320),(2,320),(3,320),(256,320), + (1,384),(2,384),(3,384),(256,384),(320,384), + (1,448),(2,448),(3,448),(256,448),(320,448),(384,448), + (1,512),(2,512),(3,512),(256,512),(320,512),(384,512),(448,512), + (1,576),(2,576),(3,576),(256,576),(320,576),(384,576),(448,576),(512,576), + (1,640),(2,640),(3,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), + (1,704),(2,704),(3,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), + (1,768),(2,768),(3,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), + (1,832),(2,832),(3,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (1,896),(2,896),(3,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (1,960),(2,960),(3,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(2,1024),(3,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), (1,1088) ); @@ -862,9 +862,9 @@ macro_rules! impl_not_const_generic{ } } impl_not_const_generic!(1,2); -impl_not_const_generic!(2,4); +impl_not_const_generic!(2,256); impl_not_const_generic!(3,384); -impl_not_const_generic!(4,512); +impl_not_const_generic!(256,512); impl_not_const_generic!(320,640); impl_not_const_generic!(384,768); impl_not_const_generic!(448,896); -- 2.49.1 From 7cf07569701b4e853d610e096a0648af3afddd65 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:09:06 -0700 Subject: [PATCH 09/86] 3 --- lib/fixed_wide/src/fixed.rs | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index e99cfd88..d59fa4ea 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -496,7 +496,7 @@ macro_rules! macro_repeated{ macro_rules! macro_16 { ( $macro: ident, $any:tt ) => { - macro_repeated!($macro,$any,1,2,3,256,320,384,448,512,576,640,704,768,832,896,960,1024); + macro_repeated!($macro,$any,1,2,192,256,320,384,448,512,576,640,704,768,832,896,960,1024); } } @@ -658,25 +658,25 @@ macro_rules! impl_wide_same_size_not_const_generic{ //const generics sidestepped wahoo macro_repeated!( impl_wide_not_const_generic,(), - (2,1),(3,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), - (1,2), (3,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), - (1,3),(2,3), (256,3),(320,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3), - (1,256),(2,256),(3,256), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256), - (1,320),(2,320),(3,320),(256,320), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320), - (1,384),(2,384),(3,384),(256,384),(320,384), (448,384),(512,384),(576,384),(640,384), - (1,448),(2,448),(3,448),(256,448),(320,448),(384,448), (512,448),(576,448), - (1,512),(2,512),(3,512),(256,512),(320,512),(384,512),(448,512), (576,512), - (1,576),(2,576),(3,576),(256,576),(320,576),(384,576),(448,576), - (1,640),(2,640),(3,640),(256,640),(320,640),(384,640), - (1,704),(2,704),(3,704),(256,704),(320,704), - (1,768),(2,768),(3,768),(256,768), - (1,832),(2,832),(3,832), + (2,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), + (1,2), (192,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), + (1,192),(2,192), (256,192),(320,192),(384,192),(448,192),(512,192),(576,192),(640,192),(704,192),(768,192),(832,192), + (1,256),(2,256),(192,256), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256), + (1,320),(2,320),(192,320),(256,320), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320), + (1,384),(2,384),(192,384),(256,384),(320,384), (448,384),(512,384),(576,384),(640,384), + (1,448),(2,448),(192,448),(256,448),(320,448),(384,448), (512,448),(576,448), + (1,512),(2,512),(192,512),(256,512),(320,512),(384,512),(448,512), (576,512), + (1,576),(2,576),(192,576),(256,576),(320,576),(384,576),(448,576), + (1,640),(2,640),(192,640),(256,640),(320,640),(384,640), + (1,704),(2,704),(192,704),(256,704),(320,704), + (1,768),(2,768),(192,768),(256,768), + (1,832),(2,832),(192,832), (1,896),(2,896), (1,960) ); macro_repeated!( impl_wide_same_size_not_const_generic,(), - 1,2,3,256,320,384,448,512 + 1,2,192,256,320,384,448,512 ); #[derive(Debug,Eq,PartialEq)] @@ -777,9 +777,9 @@ macro_rules! impl_widen_not_const_generic{ macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(3,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), - (3,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), - (256,3),(320,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), + (2,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (192,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (256,192),(320,192),(384,192),(448,192),(512,192),(576,192),(640,192),(704,192),(768,192),(832,192),(896,192),(960,192),(1024,192), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256),(832,256),(896,256),(960,256),(1024,256), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320),(768,320),(832,320),(896,320),(960,320),(1024,320), (448,384),(512,384),(576,384),(640,384),(704,384),(768,384),(832,384),(896,384),(960,384),(1024,384), @@ -796,20 +796,20 @@ macro_repeated!( macro_repeated!( impl_widen_not_const_generic,(), (1,2), - (1,3),(2,3), - (1,256),(2,256),(3,256), - (1,320),(2,320),(3,320),(256,320), - (1,384),(2,384),(3,384),(256,384),(320,384), - (1,448),(2,448),(3,448),(256,448),(320,448),(384,448), - (1,512),(2,512),(3,512),(256,512),(320,512),(384,512),(448,512), - (1,576),(2,576),(3,576),(256,576),(320,576),(384,576),(448,576),(512,576), - (1,640),(2,640),(3,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), - (1,704),(2,704),(3,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), - (1,768),(2,768),(3,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), - (1,832),(2,832),(3,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), - (1,896),(2,896),(3,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), - (1,960),(2,960),(3,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(2,1024),(3,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (1,192),(2,192), + (1,256),(2,256),(192,256), + (1,320),(2,320),(192,320),(256,320), + (1,384),(2,384),(192,384),(256,384),(320,384), + (1,448),(2,448),(192,448),(256,448),(320,448),(384,448), + (1,512),(2,512),(192,512),(256,512),(320,512),(384,512),(448,512), + (1,576),(2,576),(192,576),(256,576),(320,576),(384,576),(448,576),(512,576), + (1,640),(2,640),(192,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), + (1,704),(2,704),(192,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), + (1,768),(2,768),(192,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), + (1,832),(2,832),(192,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (1,896),(2,896),(192,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (1,960),(2,960),(192,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(2,1024),(192,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), (1,1088) ); @@ -863,7 +863,7 @@ macro_rules! impl_not_const_generic{ } impl_not_const_generic!(1,2); impl_not_const_generic!(2,256); -impl_not_const_generic!(3,384); +impl_not_const_generic!(192,384); impl_not_const_generic!(256,512); impl_not_const_generic!(320,640); impl_not_const_generic!(384,768); -- 2.49.1 From 37873e99d50b9407923b987d22733490af984783 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:09:38 -0700 Subject: [PATCH 10/86] 2 --- lib/fixed_wide/src/fixed.rs | 70 ++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index d59fa4ea..ebed48be 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -496,7 +496,7 @@ macro_rules! macro_repeated{ macro_rules! macro_16 { ( $macro: ident, $any:tt ) => { - macro_repeated!($macro,$any,1,2,192,256,320,384,448,512,576,640,704,768,832,896,960,1024); + macro_repeated!($macro,$any,1,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024); } } @@ -658,25 +658,25 @@ macro_rules! impl_wide_same_size_not_const_generic{ //const generics sidestepped wahoo macro_repeated!( impl_wide_not_const_generic,(), - (2,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), - (1,2), (192,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2), - (1,192),(2,192), (256,192),(320,192),(384,192),(448,192),(512,192),(576,192),(640,192),(704,192),(768,192),(832,192), - (1,256),(2,256),(192,256), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256), - (1,320),(2,320),(192,320),(256,320), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320), - (1,384),(2,384),(192,384),(256,384),(320,384), (448,384),(512,384),(576,384),(640,384), - (1,448),(2,448),(192,448),(256,448),(320,448),(384,448), (512,448),(576,448), - (1,512),(2,512),(192,512),(256,512),(320,512),(384,512),(448,512), (576,512), - (1,576),(2,576),(192,576),(256,576),(320,576),(384,576),(448,576), - (1,640),(2,640),(192,640),(256,640),(320,640),(384,640), - (1,704),(2,704),(192,704),(256,704),(320,704), - (1,768),(2,768),(192,768),(256,768), - (1,832),(2,832),(192,832), - (1,896),(2,896), + (128,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), + (1,128), (192,128),(256,128),(320,128),(384,128),(448,128),(512,128),(576,128),(640,128),(704,128),(768,128),(832,128),(896,128), + (1,192),(128,192), (256,192),(320,192),(384,192),(448,192),(512,192),(576,192),(640,192),(704,192),(768,192),(832,192), + (1,256),(128,256),(192,256), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256), + (1,320),(128,320),(192,320),(256,320), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320), + (1,384),(128,384),(192,384),(256,384),(320,384), (448,384),(512,384),(576,384),(640,384), + (1,448),(128,448),(192,448),(256,448),(320,448),(384,448), (512,448),(576,448), + (1,512),(128,512),(192,512),(256,512),(320,512),(384,512),(448,512), (576,512), + (1,576),(128,576),(192,576),(256,576),(320,576),(384,576),(448,576), + (1,640),(128,640),(192,640),(256,640),(320,640),(384,640), + (1,704),(128,704),(192,704),(256,704),(320,704), + (1,768),(128,768),(192,768),(256,768), + (1,832),(128,832),(192,832), + (1,896),(128,896), (1,960) ); macro_repeated!( impl_wide_same_size_not_const_generic,(), - 1,2,192,256,320,384,448,512 + 1,128,192,256,320,384,448,512 ); #[derive(Debug,Eq,PartialEq)] @@ -777,8 +777,8 @@ macro_rules! impl_widen_not_const_generic{ macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), - (192,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (128,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (192,128),(256,128),(320,128),(384,128),(448,128),(512,128),(576,128),(640,128),(704,128),(768,128),(832,128),(896,128),(960,128),(1024,128), (256,192),(320,192),(384,192),(448,192),(512,192),(576,192),(640,192),(704,192),(768,192),(832,192),(896,192),(960,192),(1024,192), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256),(832,256),(896,256),(960,256),(1024,256), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320),(768,320),(832,320),(896,320),(960,320),(1024,320), @@ -795,21 +795,21 @@ macro_repeated!( ); macro_repeated!( impl_widen_not_const_generic,(), - (1,2), - (1,192),(2,192), - (1,256),(2,256),(192,256), - (1,320),(2,320),(192,320),(256,320), - (1,384),(2,384),(192,384),(256,384),(320,384), - (1,448),(2,448),(192,448),(256,448),(320,448),(384,448), - (1,512),(2,512),(192,512),(256,512),(320,512),(384,512),(448,512), - (1,576),(2,576),(192,576),(256,576),(320,576),(384,576),(448,576),(512,576), - (1,640),(2,640),(192,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), - (1,704),(2,704),(192,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), - (1,768),(2,768),(192,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), - (1,832),(2,832),(192,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), - (1,896),(2,896),(192,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), - (1,960),(2,960),(192,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(2,1024),(192,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (1,128), + (1,192),(128,192), + (1,256),(128,256),(192,256), + (1,320),(128,320),(192,320),(256,320), + (1,384),(128,384),(192,384),(256,384),(320,384), + (1,448),(128,448),(192,448),(256,448),(320,448),(384,448), + (1,512),(128,512),(192,512),(256,512),(320,512),(384,512),(448,512), + (1,576),(128,576),(192,576),(256,576),(320,576),(384,576),(448,576),(512,576), + (1,640),(128,640),(192,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), + (1,704),(128,704),(192,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), + (1,768),(128,768),(192,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), + (1,832),(128,832),(192,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (1,896),(128,896),(192,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (1,960),(128,960),(192,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(128,1024),(192,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), (1,1088) ); @@ -861,8 +861,8 @@ macro_rules! impl_not_const_generic{ } } } -impl_not_const_generic!(1,2); -impl_not_const_generic!(2,256); +impl_not_const_generic!(1,128); +impl_not_const_generic!(128,256); impl_not_const_generic!(192,384); impl_not_const_generic!(256,512); impl_not_const_generic!(320,640); -- 2.49.1 From d6ad588079b371dc64c4faaab61059f6e4588a66 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:10:37 -0700 Subject: [PATCH 11/86] 1 --- lib/fixed_wide/src/fixed.rs | 70 ++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index ebed48be..a8c96a8e 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -496,7 +496,7 @@ macro_rules! macro_repeated{ macro_rules! macro_16 { ( $macro: ident, $any:tt ) => { - macro_repeated!($macro,$any,1,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024); + macro_repeated!($macro,$any,64,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024); } } @@ -658,25 +658,25 @@ macro_rules! impl_wide_same_size_not_const_generic{ //const generics sidestepped wahoo macro_repeated!( impl_wide_not_const_generic,(), - (128,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1), - (1,128), (192,128),(256,128),(320,128),(384,128),(448,128),(512,128),(576,128),(640,128),(704,128),(768,128),(832,128),(896,128), - (1,192),(128,192), (256,192),(320,192),(384,192),(448,192),(512,192),(576,192),(640,192),(704,192),(768,192),(832,192), - (1,256),(128,256),(192,256), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256), - (1,320),(128,320),(192,320),(256,320), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320), - (1,384),(128,384),(192,384),(256,384),(320,384), (448,384),(512,384),(576,384),(640,384), - (1,448),(128,448),(192,448),(256,448),(320,448),(384,448), (512,448),(576,448), - (1,512),(128,512),(192,512),(256,512),(320,512),(384,512),(448,512), (576,512), - (1,576),(128,576),(192,576),(256,576),(320,576),(384,576),(448,576), - (1,640),(128,640),(192,640),(256,640),(320,640),(384,640), - (1,704),(128,704),(192,704),(256,704),(320,704), - (1,768),(128,768),(192,768),(256,768), - (1,832),(128,832),(192,832), - (1,896),(128,896), - (1,960) + (128,64),(192,64),(256,64),(320,64),(384,64),(448,64),(512,64),(576,64),(640,64),(704,64),(768,64),(832,64),(896,64),(960,64), + (64,128), (192,128),(256,128),(320,128),(384,128),(448,128),(512,128),(576,128),(640,128),(704,128),(768,128),(832,128),(896,128), + (64,192),(128,192), (256,192),(320,192),(384,192),(448,192),(512,192),(576,192),(640,192),(704,192),(768,192),(832,192), + (64,256),(128,256),(192,256), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256), + (64,320),(128,320),(192,320),(256,320), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320), + (64,384),(128,384),(192,384),(256,384),(320,384), (448,384),(512,384),(576,384),(640,384), + (64,448),(128,448),(192,448),(256,448),(320,448),(384,448), (512,448),(576,448), + (64,512),(128,512),(192,512),(256,512),(320,512),(384,512),(448,512), (576,512), + (64,576),(128,576),(192,576),(256,576),(320,576),(384,576),(448,576), + (64,640),(128,640),(192,640),(256,640),(320,640),(384,640), + (64,704),(128,704),(192,704),(256,704),(320,704), + (64,768),(128,768),(192,768),(256,768), + (64,832),(128,832),(192,832), + (64,896),(128,896), + (64,960) ); macro_repeated!( impl_wide_same_size_not_const_generic,(), - 1,128,192,256,320,384,448,512 + 64,128,192,256,320,384,448,512 ); #[derive(Debug,Eq,PartialEq)] @@ -777,7 +777,7 @@ macro_rules! impl_widen_not_const_generic{ macro_repeated!( impl_narrow_not_const_generic,(), - (128,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (128,64),(192,64),(256,64),(320,64),(384,64),(448,64),(512,64),(576,64),(640,64),(704,64),(768,64),(832,64),(896,64),(960,64),(1024,64),(1088,64), (192,128),(256,128),(320,128),(384,128),(448,128),(512,128),(576,128),(640,128),(704,128),(768,128),(832,128),(896,128),(960,128),(1024,128), (256,192),(320,192),(384,192),(448,192),(512,192),(576,192),(640,192),(704,192),(768,192),(832,192),(896,192),(960,192),(1024,192), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256),(832,256),(896,256),(960,256),(1024,256), @@ -795,22 +795,22 @@ macro_repeated!( ); macro_repeated!( impl_widen_not_const_generic,(), - (1,128), - (1,192),(128,192), - (1,256),(128,256),(192,256), - (1,320),(128,320),(192,320),(256,320), - (1,384),(128,384),(192,384),(256,384),(320,384), - (1,448),(128,448),(192,448),(256,448),(320,448),(384,448), - (1,512),(128,512),(192,512),(256,512),(320,512),(384,512),(448,512), - (1,576),(128,576),(192,576),(256,576),(320,576),(384,576),(448,576),(512,576), - (1,640),(128,640),(192,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), - (1,704),(128,704),(192,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), - (1,768),(128,768),(192,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), - (1,832),(128,832),(192,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), - (1,896),(128,896),(192,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), - (1,960),(128,960),(192,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(128,1024),(192,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), - (1,1088) + (64,128), + (64,192),(128,192), + (64,256),(128,256),(192,256), + (64,320),(128,320),(192,320),(256,320), + (64,384),(128,384),(192,384),(256,384),(320,384), + (64,448),(128,448),(192,448),(256,448),(320,448),(384,448), + (64,512),(128,512),(192,512),(256,512),(320,512),(384,512),(448,512), + (64,576),(128,576),(192,576),(256,576),(320,576),(384,576),(448,576),(512,576), + (64,640),(128,640),(192,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), + (64,704),(128,704),(192,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), + (64,768),(128,768),(192,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), + (64,832),(128,832),(192,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (64,896),(128,896),(192,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (64,960),(128,960),(192,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (64,1024),(128,1024),(192,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (64,1088) ); macro_rules! impl_not_const_generic{ @@ -861,7 +861,7 @@ macro_rules! impl_not_const_generic{ } } } -impl_not_const_generic!(1,128); +impl_not_const_generic!(64,128); impl_not_const_generic!(128,256); impl_not_const_generic!(192,384); impl_not_const_generic!(256,512); -- 2.49.1 From 1753e8043822dba79da2c3466f535e999190644b Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:16:13 -0700 Subject: [PATCH 12/86] fix macro madness --- lib/fixed_wide/src/fixed.rs | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index a8c96a8e..d582f524 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -433,8 +433,8 @@ macro_rules! impl_divide_operator_not_const_generic { #[inline] pub fn [](self,other:Self)->Self{ //this only needs to be $width+F as u32/64+1 but MUH CONST GENERICS!!!!! - let lhs=self.bits.as_::>().shl(F as u32); - let rhs=other.bits.as_::>(); + let lhs=self.bits.as_::>().shl(F as u32); + let rhs=other.bits.as_::>(); Self::from_bits(lhs.div_euclid(rhs).as_()) } } @@ -554,7 +554,7 @@ impl_shift_operator!( Fixed, Shr, shr, Self ); macro_rules! impl_wide_operators{ ($lhs:expr,$rhs:expr)=>{ impl core::ops::Mul>1}>> for Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}>{ - type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)>>1}>; + type Output=Fixed<{($lhs+$rhs)/BNUM_DIGIT_WIDTH},{($lhs+$rhs)>>1}>; #[inline] fn mul(self, other: Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Self::Output{ paste::item!{ @@ -564,7 +564,7 @@ macro_rules! impl_wide_operators{ } #[cfg(not(feature="deferred-division"))] impl core::ops::Div>1}>> for Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}>{ - type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)>>1}>; + type Output=Fixed<{($lhs+$rhs)/BNUM_DIGIT_WIDTH},{($lhs+$rhs)>>1}>; #[inline] fn div(self, other: Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Self::Output{ paste::item!{ @@ -574,7 +574,7 @@ macro_rules! impl_wide_operators{ } #[cfg(feature="deferred-division")] impl ratio_ops::ratio::Divide>1}>> for Fixed<{$lhs/BNUM_DIGIT_WIDTH},{$lhs>>1}>{ - type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)>>1}>; + type Output=Fixed<{($lhs+$rhs)/BNUM_DIGIT_WIDTH},{($lhs+$rhs)>>1}>; #[inline] fn divide(self, other: Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Self::Output{ paste::item!{ @@ -597,19 +597,19 @@ macro_rules! impl_wide_not_const_generic{ { paste::item!{ #[inline] - pub fn [](self,rhs:Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Fixed<{$lhs+$rhs},{($lhs+$rhs)>>1}>{ - let lhs=self.bits.as_::>(); - let rhs=rhs.bits.as_::>(); + pub fn [](self,rhs:Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Fixed<{($lhs+$rhs)/BNUM_DIGIT_WIDTH},{($lhs+$rhs)>>1}>{ + let lhs=self.bits.as_::>(); + let rhs=rhs.bits.as_::>(); Fixed::from_bits(lhs*rhs) } /// This operation cannot represent the fraction exactly, /// but it shapes the output to have precision for the /// largest and smallest possible fractions. #[inline] - pub fn [](self,rhs:Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Fixed<{$lhs+$rhs},{($lhs+$rhs)>>1}>{ + pub fn [](self,rhs:Fixed<{$rhs/BNUM_DIGIT_WIDTH},{$rhs>>1}>)->Fixed<{($lhs+$rhs)/BNUM_DIGIT_WIDTH},{($lhs+$rhs)>>1}>{ // (lhs/2^LHS_FRAC)/(rhs/2^RHS_FRAC) - let lhs=self.bits.as_::>().shl($rhs); - let rhs=rhs.bits.as_::>(); + let lhs=self.bits.as_::>().shl($rhs); + let rhs=rhs.bits.as_::>(); Fixed::from_bits(lhs.div_euclid(rhs)) } } @@ -627,9 +627,9 @@ macro_rules! impl_wide_same_size_not_const_generic{ { paste::item!{ #[inline] - pub fn [](self,rhs:Fixed<{$width/BNUM_DIGIT_WIDTH},{$width>>1}>)->Fixed<{$width*2},{$width*2>>1}>{ + pub fn [](self,rhs:Fixed<{$width/BNUM_DIGIT_WIDTH},{$width>>1}>)->Fixed<{$width*2/BNUM_DIGIT_WIDTH},{$width*2>>1}>{ let (low,high)=self.bits.unsigned_abs().widening_mul(rhs.bits.unsigned_abs()); - let out:Int::<{$width*2}>=unsafe{core::mem::transmute([low,high])}; + let out:Int::<{$width*2/BNUM_DIGIT_WIDTH}>=unsafe{core::mem::transmute([low,high])}; if self.is_negative()==rhs.is_negative(){ Fixed::from_bits(out) }else{ @@ -642,10 +642,10 @@ macro_rules! impl_wide_same_size_not_const_generic{ /// but it shapes the output to have precision for the /// largest and smallest possible fractions. #[inline] - pub fn [](self,rhs:Fixed<{$width/BNUM_DIGIT_WIDTH},{$width>>1}>)->Fixed<{$width*2},{$width*2>>1}>{ + pub fn [](self,rhs:Fixed<{$width/BNUM_DIGIT_WIDTH},{$width>>1}>)->Fixed<{$width*2/BNUM_DIGIT_WIDTH},{$width*2>>1}>{ // (lhs/2^LHS_FRAC)/(rhs/2^RHS_FRAC) - let lhs=self.bits.as_::>().shl($width); - let rhs=rhs.bits.as_::>(); + let lhs=self.bits.as_::>().shl($width); + let rhs=rhs.bits.as_::>(); Fixed::from_bits(lhs.div_euclid(rhs)) } } @@ -715,10 +715,10 @@ macro_rules! impl_narrow_not_const_generic{ } #[inline] pub fn [](self)->Result>1}>,NarrowError>{ - if Fixed::<$rhs,{$rhs>>1}>::MAX.[]().bits>1}>::MAX.[]().bits>1}>::MIN.[]().bits{ + if self.bits>1}>::MIN.[]().bits{ return Err(NarrowError::Underflow); } Ok(self.[]()) @@ -815,7 +815,7 @@ macro_repeated!( macro_rules! impl_not_const_generic{ ($n:expr,$_2n:expr)=>{ - impl Fixed<$n,{$n>>1}>{ + impl Fixed<{$n/BNUM_DIGIT_WIDTH},{$n>>1}>{ paste::item!{ #[inline] pub fn sqrt_unchecked(self)->Self{ -- 2.49.1 From 960179043b9a8b0a7c99a256f8bbd3d6de39ba10 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:20:56 -0700 Subject: [PATCH 13/86] fix wrap_* calls --- engine/physics/src/face_crawler.rs | 4 ++-- engine/physics/src/minimum_difference.rs | 4 ++-- engine/physics/src/minkowski.rs | 16 ++++++++------- engine/physics/src/model.rs | 2 +- engine/physics/src/physics.rs | 12 +++++------ engine/physics/src/push_solve.rs | 12 +++++------ lib/common/src/gameplay_style.rs | 22 ++++++++++---------- lib/common/src/integer.rs | 8 ++++---- lib/fixed_wide/src/tests.rs | 26 ++++++++++++------------ lib/rbx_loader/src/primitives.rs | 6 +++--- 10 files changed, 57 insertions(+), 55 deletions(-) diff --git a/engine/physics/src/face_crawler.rs b/engine/physics/src/face_crawler.rs index f99aa134..dc170a77 100644 --- a/engine/physics/src/face_crawler.rs +++ b/engine/physics/src/face_crawler.rs @@ -105,7 +105,7 @@ impl,Offset=I128F128,Position=Planar64Vec3, //WARNING: d is moved out of the *2 block because of adding two vertices! //WARNING: precision is swept under the rug! //wrap for speed - for dt in I128F128::zeroes2(n.dot(trajectory.position*2-(mesh.vert(v0)+mesh.vert(v1))).wrap_4(),n.dot(trajectory.velocity).wrap_4()*2,n.dot(trajectory.acceleration).wrap_4()){ + for dt in I128F128::zeroes2(n.dot(trajectory.position*2-(mesh.vert(v0)+mesh.vert(v1))).wrap_256(),n.dot(trajectory.velocity).wrap_256()*2,n.dot(trajectory.acceleration).wrap_256()){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ upper_bound=Bound::Included(dt); best_transition=Transition::Next(FEV::Edge(directed_edge_id.as_undirected()),dt); @@ -128,7 +128,7 @@ impl,Offset=I128F128,Position=Planar64Vec3, let n=face_n.cross(edge_n)*((i as i64)*2-1); //WARNING yada yada d *2 //wrap for speed - for dt in I128F128::zeroes2(n.dot(delta_pos).wrap_4(),n.dot(trajectory.velocity).wrap_4()*2,n.dot(trajectory.acceleration).wrap_4()){ + for dt in I128F128::zeroes2(n.dot(delta_pos).wrap_256(),n.dot(trajectory.velocity).wrap_256()*2,n.dot(trajectory.acceleration).wrap_256()){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ upper_bound=Bound::Included(dt); best_transition=Transition::Next(FEV::Face(edge_face_id),dt); diff --git a/engine/physics/src/minimum_difference.rs b/engine/physics/src/minimum_difference.rs index f6fb82b1..1224670f 100644 --- a/engine/physics/src/minimum_difference.rs +++ b/engine/physics/src/minimum_difference.rs @@ -578,7 +578,7 @@ impl ThickPlane{ let normal=(p1-p0).cross(p2-p0); // Allow ~ 2*sqrt(3) units of thickness on the plane // This is to account for the variance of two voxels across the longest diagonal - let epsilon=(normal.length()*(Planar64::EPSILON*3)).wrap_3(); + let epsilon=(normal.length()*(Planar64::EPSILON*3)).wrap_196(); Self{point,normal,epsilon} } } @@ -658,7 +658,7 @@ impl,C:Contains> EVFinder<'_,M,C> let distance_squared={ let c=diff.cross(edge_n); //wrap for speed - (c.dot(c)/edge_nn).divide().wrap_2() + (c.dot(c)/edge_nn).divide().wrap_128() }; if distance_squared<=self.best_distance_squared{ best_transition=EV::Edge(directed_edge_id.as_undirected()); diff --git a/engine/physics/src/minkowski.rs b/engine/physics/src/minkowski.rs index bbb87486..a25ed6f5 100644 --- a/engine/physics/src/minkowski.rs +++ b/engine/physics/src/minkowski.rs @@ -1,6 +1,8 @@ use core::ops::{Bound,RangeBounds}; -use strafesnet_common::integer::{Planar64Vec3,Ratio,Fixed,vec3::Vector3}; +use strafesnet_common::integer::fixed_types::{I96F96,I128F128}; +use strafesnet_common::integer::vec3::Vector3; +use strafesnet_common::integer::{Planar64Vec3,Ratio,Fixed}; use crate::model::into_giga_time; use crate::model::{SubmeshVertId,SubmeshEdgeId,SubmeshDirectedEdgeId,SubmeshFaceId,TransformedMesh,GigaTime}; use crate::mesh_query::{MeshQuery,MeshTopology,DirectedEdge,UndirectedEdge}; @@ -142,7 +144,7 @@ impl MinkowskiMesh<'_>{ //WARNING! d outside of *2 //WARNING: truncated precision //wrap for speed - for dt in Fixed::<4,128>::zeroes2(((n.dot(trajectory.position))*2-d).wrap_4(),n.dot(trajectory.velocity).wrap_4()*2,n.dot(trajectory.acceleration).wrap_4()){ + for dt in I128F128::zeroes2(((n.dot(trajectory.position))*2-d).wrap_256(),n.dot(trajectory.velocity).wrap_256()*2,n.dot(trajectory.acceleration).wrap_256()){ if low(&start_time,&dt)&&upp(&dt,&best_time)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ best_time=Bound::Included(dt); best_edge=Some((directed_edge_id,dt)); @@ -159,8 +161,8 @@ impl MinkowskiMesh<'_>{ impl MeshQuery for MinkowskiMesh<'_>{ type Direction=Planar64Vec3; type Position=Planar64Vec3; - type Normal=Vector3>; - type Offset=Fixed<4,128>; + type Normal=Vector3; + type Offset=I128F128; // TODO: relative d fn face_nd(&self,face_id:MinkowskiFace)->(Self::Normal,Self::Offset){ match face_id{ @@ -240,7 +242,7 @@ impl MeshTopology for MinkowskiMesh<'_>{ for face_n in &v1f_n{ //add reflected mesh1 faces //wrap for speed - face_normals.push(*face_n-(n*face_n.dot(n)*2/nn).divide().wrap_3()); + face_normals.push(*face_n-(n*face_n.dot(n)*2/nn).divide().wrap_196()); } if is_empty_volume(&face_normals){ f(MinkowskiDirectedEdge::EdgeVert(directed_edge_id,v1)); @@ -255,7 +257,7 @@ impl MeshTopology for MinkowskiMesh<'_>{ // make a set of faces from mesh1's perspective for face_n in &v0f_n{ //wrap for speed - face_normals.push(*face_n-(n*face_n.dot(n)*2/nn).divide().wrap_3()); + face_normals.push(*face_n-(n*face_n.dot(n)*2/nn).divide().wrap_196()); } if is_empty_volume(&face_normals){ f(MinkowskiDirectedEdge::VertEdge(v0,directed_edge_id)); @@ -375,7 +377,7 @@ impl MeshTopology for MinkowskiMesh<'_>{ } } -fn is_empty_volume(normals:&[Vector3>])->bool{ +fn is_empty_volume(normals:&[Vector3])->bool{ let len=normals.len(); for i in 0..len-1{ for j in i+1..len{ diff --git a/engine/physics/src/model.rs b/engine/physics/src/model.rs index 125937cb..a860e944 100644 --- a/engine/physics/src/model.rs +++ b/engine/physics/src/model.rs @@ -507,7 +507,7 @@ impl MeshQuery for TransformedMesh<'_>{ } fn vert(&self,vert_id:SubmeshVertId)->Planar64Vec3{ // wrap for speed - self.transform.vertex.transform_point3(self.view.vert(vert_id)).wrap_1() + self.transform.vertex.transform_point3(self.view.vert(vert_id)).wrap_64() } fn hint_point(&self)->Planar64Vec3{ self.transform.vertex.translation diff --git a/engine/physics/src/physics.rs b/engine/physics/src/physics.rs index d68625d5..cfbe61c2 100644 --- a/engine/physics/src/physics.rs +++ b/engine/physics/src/physics.rs @@ -129,7 +129,7 @@ impl TransientAcceleration{ }else{ //normal friction acceleration is clippedAcceleration.dot(normal)*friction TransientAcceleration::Reachable{ - acceleration:target_diff.with_length(accel).divide().wrap_1(), + acceleration:target_diff.with_length(accel).divide().wrap_64(), time:time+Time::from((target_diff.length()/accel).divide().clamp_1()) } } @@ -481,12 +481,12 @@ impl StyleHelper for StyleModifiers{ } fn get_y_control_dir(&self,camera:&PhysicsCamera,controls:Controls)->Planar64Vec3{ - (camera.rotation_y()*self.get_control_dir(controls)).wrap_1() + (camera.rotation_y()*self.get_control_dir(controls)).wrap_64() } fn get_propulsion_control_dir(&self,camera:&PhysicsCamera,controls:Controls)->Planar64Vec3{ //don't interpolate this! discrete mouse movement, constant acceleration - (camera.rotation()*self.get_control_dir(controls)).wrap_1() + (camera.rotation()*self.get_control_dir(controls)).wrap_64() } fn calculate_mesh(&self)->HitboxMesh{ let mesh=match self.hitbox.mesh{ @@ -1251,7 +1251,7 @@ fn contact_normal( let minkowski=MinkowskiMesh::minkowski_sum(model_mesh,hitbox_mesh.transformed_mesh()); // TODO: normalize to i64::MAX>>1 // wrap for speed - minkowski.face_nd(face_id).0.wrap_1() + minkowski.face_nd(face_id).0.wrap_64() } fn recalculate_touching( @@ -1555,7 +1555,7 @@ fn collision_start_contact( Some(gameplay_attributes::ContactingBehaviour::Surf)=>(), Some(gameplay_attributes::ContactingBehaviour::Cling)=>println!("Unimplemented!"), &Some(gameplay_attributes::ContactingBehaviour::Elastic(elasticity))=>{ - let reflected_velocity=body.velocity+((body.velocity-incident_velocity)*Planar64::raw(elasticity as i64+1)).wrap_1(); + let reflected_velocity=body.velocity+((body.velocity-incident_velocity)*Planar64::raw(elasticity as i64+1)).wrap_64(); set_velocity(body,touching,models,hitbox_mesh,reflected_velocity); }, Some(gameplay_attributes::ContactingBehaviour::Ladder(contacting_ladder))=> @@ -1809,7 +1809,7 @@ fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:Tim // manually advance time let extrapolated_body=state.body.with_acceleration(state.acceleration(data)).extrapolated_body(state.time); let camera_mat=state.camera.simulate_move_rotation_y(state.input_state.lerp_delta(state.time).x); - if let Some(ticked_velocity)=strafe_settings.tick_velocity(extrapolated_body.velocity,(camera_mat*control_dir).with_length(Planar64::ONE).divide().wrap_1()){ + if let Some(ticked_velocity)=strafe_settings.tick_velocity(extrapolated_body.velocity,(camera_mat*control_dir).with_length(Planar64::ONE).divide().wrap_64()){ state.body=extrapolated_body; //this is wrong but will work ig //need to note which push planes activate in push solve and keep those diff --git a/engine/physics/src/push_solve.rs b/engine/physics/src/push_solve.rs index 0d2c698c..280350b7 100644 --- a/engine/physics/src/push_solve.rs +++ b/engine/physics/src/push_solve.rs @@ -152,18 +152,18 @@ const fn get_push_ray_0(point:Planar64Vec3)->Ray{ } fn get_push_ray_1(point:Planar64Vec3,c0:&Contact)->Option{ //wrap for speed - let direction=solve1(c0)?.divide().wrap_1(); + let direction=solve1(c0)?.divide().wrap_64(); let [s0]=decompose1(direction,c0.velocity)?; if s0.lt_ratio(RATIO_ZERO){ return None; } let origin=point+solve1( &c0.relative_to(point), - )?.divide().wrap_1(); + )?.divide().wrap_64(); Some(Ray{origin,direction}) } fn get_push_ray_2(point:Planar64Vec3,c0:&Contact,c1:&Contact)->Option{ - let direction=solve2(c0,c1)?.divide().wrap_1(); + let direction=solve2(c0,c1)?.divide().wrap_64(); let [s0,s1]=decompose2(direction,c0.velocity,c1.velocity)?; if s0.lt_ratio(RATIO_ZERO)||s1.lt_ratio(RATIO_ZERO){ return None; @@ -171,11 +171,11 @@ fn get_push_ray_2(point:Planar64Vec3,c0:&Contact,c1:&Contact)->Option{ let origin=point+solve2( &c0.relative_to(point), &c1.relative_to(point), - )?.divide().wrap_1(); + )?.divide().wrap_64(); Some(Ray{origin,direction}) } fn get_push_ray_3(point:Planar64Vec3,c0:&Contact,c1:&Contact,c2:&Contact)->Option{ - let direction=solve3(c0,c1,c2)?.divide().wrap_1(); + let direction=solve3(c0,c1,c2)?.divide().wrap_64(); let [s0,s1,s2]=decompose3(direction,c0.velocity,c1.velocity,c2.velocity)?; if s0.lt_ratio(RATIO_ZERO)||s1.lt_ratio(RATIO_ZERO)||s2.lt_ratio(RATIO_ZERO){ return None; @@ -184,7 +184,7 @@ fn get_push_ray_3(point:Planar64Vec3,c0:&Contact,c1:&Contact,c2:&Contact)->Optio &c0.relative_to(point), &c1.relative_to(point), &c2.relative_to(point), - )?.divide().wrap_1(); + )?.divide().wrap_64(); Some(Ray{origin,direction}) } diff --git a/lib/common/src/gameplay_style.rs b/lib/common/src/gameplay_style.rs index 464c99a8..d1dbe1df 100644 --- a/lib/common/src/gameplay_style.rs +++ b/lib/common/src/gameplay_style.rs @@ -75,7 +75,7 @@ impl JumpImpulse{ let v_g=gravity.dot(velocity); //do it backwards let radicand=v_g*v_g+(g*height*2).widen_4(); - velocity-(*gravity*(radicand.sqrt().wrap_2()+v_g)/gg).divide().clamp_1() + velocity-(*gravity*(radicand.sqrt().wrap_128()+v_g)/gg).divide().clamp_1() }, &JumpImpulse::Linear(jump_speed)=>velocity+(jump_dir*jump_speed/jump_dir.length()).divide().clamp_1(), &JumpImpulse::Energy(_energy)=>{ @@ -91,8 +91,8 @@ impl JumpImpulse{ pub fn get_jump_deltav(&self,gravity:&Planar64Vec3,mass:Planar64)->Planar64{ //gravity.length() is actually the proper calculation because the jump is always opposite the gravity direction match self{ - &JumpImpulse::Time(time)=>(gravity.length().wrap_1()*time/2).divide().clamp_1(), - &JumpImpulse::Height(height)=>(gravity.length()*height*2).sqrt().wrap_1(), + &JumpImpulse::Time(time)=>(gravity.length().wrap_64()*time/2).divide().clamp_1(), + &JumpImpulse::Height(height)=>(gravity.length()*height*2).sqrt().wrap_64(), &JumpImpulse::Linear(deltav)=>deltav, &JumpImpulse::Energy(energy)=>(energy.sqrt()*2/mass.sqrt()).divide().clamp_1(), } @@ -129,7 +129,7 @@ impl JumpSettings{ let js=jump_speed.widen_2(); if j{ @@ -162,7 +162,7 @@ impl JumpSettings{ let js=jump_speed.widen_2(); if boost_dotbooster.boost(rel_velocity), None=>rel_velocity, }; - boost_vel+jump_dir.with_length(jump_speed).divide().wrap_1() + boost_vel+jump_dir.with_length(jump_speed).divide().wrap_64() }, } } @@ -269,7 +269,7 @@ impl StrafeSettings{ let d=velocity.dot(control_dir); let mv=self.mv.widen_2(); match dSome(velocity+(control_dir*self.air_accel_limit.map_or(mv-d,|limit|limit.widen_2().min(mv-d))).wrap_1()), + true=>Some(velocity+(control_dir*self.air_accel_limit.map_or(mv-d,|limit|limit.widen_2().min(mv-d))).wrap_64()), false=>None, } } @@ -310,7 +310,7 @@ pub struct WalkSettings{ impl WalkSettings{ pub fn accel(&self,target_diff:Planar64Vec3,gravity:Planar64Vec3)->Planar64{ //TODO: fallible walk accel - let diff_len=target_diff.length().wrap_1(); + let diff_len=target_diff.length().wrap_64(); let friction=if diff_lenbool{ //normal is not guaranteed to be unit length let ny=normal.dot(up); - let h=normal.length().wrap_1(); + let h=normal.length().wrap_64(); //remember this is a normal vector ny.is_positive()&&h*self.surf_dot::ONE*2); - let awb=a.wide_div_1_2(wide_b); + let awb=a.wide_div_64_128(wide_b); assert_eq!(awb,crate::fixed::Fixed::<3,96>::ONE*2); } @@ -122,9 +122,9 @@ fn test_wide_mul_repeated() { let a=I32F32::from(2); let b=I32F32::from(3); - let w1=a.wide_mul_1_1(b); - let w2=w1.wide_mul_2_2(w1); - let w3=w2.wide_mul_4_4(w2); + let w1=a.wide_mul_64_64(b); + let w2=w1.wide_mul_128_128(w1); + let w3=w2.wide_mul_256_256(w2); assert_eq!(w3,I256F256::from((3i128*2).pow(4))); } @@ -137,8 +137,8 @@ fn test_bint(){ #[test] fn test_wrap(){ - assert_eq!(I32F32::ONE,I256F256::ONE.wrap_1()); - assert_eq!(I32F32::NEG_ONE,I256F256::NEG_ONE.wrap_1()); + assert_eq!(I32F32::ONE,I256F256::ONE.wrap_64()); + assert_eq!(I32F32::NEG_ONE,I256F256::NEG_ONE.wrap_64()); } #[test] fn test_narrow(){ @@ -181,10 +181,10 @@ fn find_equiv_sqrt_via_f64(n:I32F32)->I32F32{ let r=I32F32::from_bits(bnum::BInt::<1>::from(i)); //mimic the behaviour of the algorithm, //return the result if it truncates to the exact answer - if (r+I32F32::EPSILON).wide_mul_1_1(r+I32F32::EPSILON)==n.wide_mul_1_1(I32F32::ONE){ + if (r+I32F32::EPSILON).wide_mul_64_64(r+I32F32::EPSILON)==n.wide_mul_64_64(I32F32::ONE){ return r+I32F32::EPSILON; } - if (r-I32F32::EPSILON).wide_mul_1_1(r-I32F32::EPSILON)==n.wide_mul_1_1(I32F32::ONE){ + if (r-I32F32::EPSILON).wide_mul_64_64(r-I32F32::EPSILON)==n.wide_mul_64_64(I32F32::ONE){ return r-I32F32::EPSILON; } return r; diff --git a/lib/rbx_loader/src/primitives.rs b/lib/rbx_loader/src/primitives.rs index bfd6afd4..beeb315c 100644 --- a/lib/rbx_loader/src/primitives.rs +++ b/lib/rbx_loader/src/primitives.rs @@ -519,7 +519,7 @@ pub fn unit_cylinder(face_descriptions:CubeFaceDescription)->Mesh{ (glam::vec2(-x as f32,y as f32).normalize()+1.0)/2.0 ) ); - let pos=mb.acquire_pos_id($end+vec3::int(0,-x,y).with_length(Planar64::ONE).divide().wrap_1()); + let pos=mb.acquire_pos_id($end+vec3::int(0,-x,y).with_length(Planar64::ONE).divide().wrap_64()); mb.acquire_vertex_id(IndexedVertex{pos,tex,normal,color}) }).collect(); @@ -560,9 +560,9 @@ pub fn unit_cylinder(face_descriptions:CubeFaceDescription)->Mesh{ let mut polygon_list=Vec::with_capacity(CubeFaceDescription::FACES); for $loop in -GON..GON{ // lo Z - let lz_dir=$lo_dir.with_length(Planar64::ONE).divide().wrap_1(); + let lz_dir=$lo_dir.with_length(Planar64::ONE).divide().wrap_64(); // hi Z - let hz_dir=$hi_dir.with_length(Planar64::ONE).divide().wrap_1(); + let hz_dir=$hi_dir.with_length(Planar64::ONE).divide().wrap_64(); // pos let lx_lz_pos=mb.acquire_pos_id(vec3::NEG_X+lz_dir); -- 2.49.1 From eaf3bd0cb5b026cc5e7c3ca6cc1d2128b2e78045 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:23:50 -0700 Subject: [PATCH 14/86] clamp_* --- engine/physics/src/body.rs | 6 +++--- engine/physics/src/physics.rs | 4 ++-- lib/common/src/gameplay_style.rs | 24 ++++++++++++------------ lib/common/src/integer.rs | 2 +- lib/fixed_wide/src/tests.rs | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/engine/physics/src/body.rs b/engine/physics/src/body.rs index 275edfd5..f04aabd3 100644 --- a/engine/physics/src/body.rs +++ b/engine/physics/src/body.rs @@ -86,12 +86,12 @@ impl Trajectory pub fn extrapolated_position(&self,time:Time)->Planar64Vec3{ let dt=time-self.time; self.position - +(self.velocity*dt).map(|elem|elem.divide().clamp_1()) - +self.acceleration.map(|elem|(dt*dt*elem/2).divide().clamp_1()) + +(self.velocity*dt).map(|elem|elem.divide().clamp_64()) + +self.acceleration.map(|elem|(dt*dt*elem/2).divide().clamp_64()) } pub fn extrapolated_velocity(&self,time:Time)->Planar64Vec3{ let dt=time-self.time; - self.velocity+(self.acceleration*dt).map(|elem|elem.divide().clamp_1()) + self.velocity+(self.acceleration*dt).map(|elem|elem.divide().clamp_64()) } pub fn extrapolated_body(&self,time:Time)->Body{ Body::new( diff --git a/engine/physics/src/physics.rs b/engine/physics/src/physics.rs index cfbe61c2..b11239b5 100644 --- a/engine/physics/src/physics.rs +++ b/engine/physics/src/physics.rs @@ -130,7 +130,7 @@ impl TransientAcceleration{ //normal friction acceleration is clippedAcceleration.dot(normal)*friction TransientAcceleration::Reachable{ acceleration:target_diff.with_length(accel).divide().wrap_64(), - time:time+Time::from((target_diff.length()/accel).divide().clamp_1()) + time:time+Time::from((target_diff.length()/accel).divide().clamp_64()) } } } @@ -1391,7 +1391,7 @@ fn teleport_to_spawn( const EPSILON:Planar64=Planar64::raw((1<<32)/16); let transform=models.get_model_transform(spawn_model_id).ok_or(TeleportToSpawnError::NoModel)?; //TODO: transform.vertex.matrix3.col(1)+transform.vertex.translation - let point=transform.vertex.transform_point3(vec3::Y).clamp_1()+Planar64Vec3::new([Planar64::ZERO,style.hitbox.halfsize.y+EPSILON,Planar64::ZERO]); + let point=transform.vertex.transform_point3(vec3::Y).clamp_64()+Planar64Vec3::new([Planar64::ZERO,style.hitbox.halfsize.y+EPSILON,Planar64::ZERO]); teleport(point,move_state,body,touching,run,mode_state,Some(mode),models,hitbox_mesh,bvh,style,camera,input_state,time); Ok(()) } diff --git a/lib/common/src/gameplay_style.rs b/lib/common/src/gameplay_style.rs index d1dbe1df..7a8e659a 100644 --- a/lib/common/src/gameplay_style.rs +++ b/lib/common/src/gameplay_style.rs @@ -66,7 +66,7 @@ impl JumpImpulse{ _mass:Planar64, )->Planar64Vec3{ match self{ - &JumpImpulse::Time(time)=>velocity-(*gravity*time).map(|t|t.divide().clamp_1()), + &JumpImpulse::Time(time)=>velocity-(*gravity*time).map(|t|t.divide().clamp_64()), &JumpImpulse::Height(height)=>{ //height==-v.y*v.y/(2*g.y); //use energy to determine max height @@ -75,9 +75,9 @@ impl JumpImpulse{ let v_g=gravity.dot(velocity); //do it backwards let radicand=v_g*v_g+(g*height*2).widen_4(); - velocity-(*gravity*(radicand.sqrt().wrap_128()+v_g)/gg).divide().clamp_1() + velocity-(*gravity*(radicand.sqrt().wrap_128()+v_g)/gg).divide().clamp_64() }, - &JumpImpulse::Linear(jump_speed)=>velocity+(jump_dir*jump_speed/jump_dir.length()).divide().clamp_1(), + &JumpImpulse::Linear(jump_speed)=>velocity+(jump_dir*jump_speed/jump_dir.length()).divide().clamp_64(), &JumpImpulse::Energy(_energy)=>{ //calculate energy //let e=gravity.dot(velocity); @@ -91,10 +91,10 @@ impl JumpImpulse{ pub fn get_jump_deltav(&self,gravity:&Planar64Vec3,mass:Planar64)->Planar64{ //gravity.length() is actually the proper calculation because the jump is always opposite the gravity direction match self{ - &JumpImpulse::Time(time)=>(gravity.length().wrap_64()*time/2).divide().clamp_1(), + &JumpImpulse::Time(time)=>(gravity.length().wrap_64()*time/2).divide().clamp_64(), &JumpImpulse::Height(height)=>(gravity.length()*height*2).sqrt().wrap_64(), &JumpImpulse::Linear(deltav)=>deltav, - &JumpImpulse::Energy(energy)=>(energy.sqrt()*2/mass.sqrt()).divide().clamp_1(), + &JumpImpulse::Energy(energy)=>(energy.sqrt()*2/mass.sqrt()).divide().clamp_64(), } } } @@ -290,7 +290,7 @@ pub struct PropulsionSettings{ } impl PropulsionSettings{ pub fn acceleration(&self,control_dir:Planar64Vec3)->Planar64Vec3{ - (control_dir*self.magnitude).clamp_1() + (control_dir*self.magnitude).clamp_64() } } @@ -316,7 +316,7 @@ impl WalkSettings{ }else{ self.kinetic_friction }; - self.accelerate.accel.min((-gravity.y*friction).clamp_1()) + self.accelerate.accel.min((-gravity.y*friction).clamp_64()) } pub fn get_walk_target_velocity(&self,control_dir:Planar64Vec3,normal:Planar64Vec3)->Planar64Vec3{ if control_dir==crate::integer::vec3::zero(){ @@ -332,7 +332,7 @@ impl WalkSettings{ if cr==crate::integer::vec3::zero(){ crate::integer::vec3::zero() }else{ - (cr.cross(normal)*self.accelerate.topspeed/((nn*(nnmm-dd)).sqrt())).divide().clamp_1() + (cr.cross(normal)*self.accelerate.topspeed/((nn*(nnmm-dd)).sqrt())).divide().clamp_64() } }else{ crate::integer::vec3::zero() @@ -368,11 +368,11 @@ impl LadderSettings{ let nnmm=nn*mm; let d=normal.dot(control_dir); let mut dd=d*d; - if (self.dot*self.dot*nnmm).clamp_4() Time{ impl From for Time{ #[inline] fn from(value:Planar64)->Self{ - Self::raw((value*Planar64::raw(1_000_000_000)).clamp_1().to_raw()) + Self::raw((value*Planar64::raw(1_000_000_000)).clamp_64().to_raw()) } } impl From> for Ratio{ diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 0a95eb2b..67e713a4 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -152,8 +152,8 @@ fn test_widen(){ } #[test] fn test_clamp(){ - assert_eq!(I32F32::ONE,I256F256::ONE.clamp_1()); - assert_eq!(I32F32::NEG_ONE,I256F256::NEG_ONE.clamp_1()); + assert_eq!(I32F32::ONE,I256F256::ONE.clamp_64()); + assert_eq!(I32F32::NEG_ONE,I256F256::NEG_ONE.clamp_64()); } #[test] fn test_sqrt(){ -- 2.49.1 From 8c7e6f4cfe497c88f5da5fdf47428fc6b109893f Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:24:11 -0700 Subject: [PATCH 15/86] narrow_* --- engine/physics/src/minimum_difference.rs | 8 ++++---- engine/physics/src/model.rs | 4 ++-- engine/physics/src/physics.rs | 4 ++-- lib/bsp_loader/src/brush.rs | 2 +- lib/common/src/gameplay_style.rs | 16 ++++++++-------- lib/fixed_wide/src/tests.rs | 4 ++-- lib/rbx_loader/src/rbx.rs | 18 +++++++++--------- lib/snf/src/map.rs | 2 +- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/engine/physics/src/minimum_difference.rs b/engine/physics/src/minimum_difference.rs index 1224670f..f9070093 100644 --- a/engine/physics/src/minimum_difference.rs +++ b/engine/physics/src/minimum_difference.rs @@ -103,7 +103,7 @@ const fn choose_any_direction()->Planar64Vec3{ fn narrow_dir2(dir:Vector3)->Planar64Vec3{ if dir==vec3::zero(){ - return dir.narrow_1().unwrap(); + return dir.narrow_64().unwrap(); } let x=dir.x.as_bits().unsigned_abs().bits(); let y=dir.y.as_bits().unsigned_abs().bits(); @@ -114,11 +114,11 @@ fn narrow_dir2(dir:Vector3)->Planar64Vec3{ dir>>(big-MAX_BITS) }else{ dir - }.narrow_1().unwrap() + }.narrow_64().unwrap() } fn narrow_dir3(dir:Vector3)->Planar64Vec3{ if dir==vec3::zero(){ - return dir.narrow_1().unwrap(); + return dir.narrow_64().unwrap(); } let x=dir.x.as_bits().unsigned_abs().bits(); let y=dir.y.as_bits().unsigned_abs().bits(); @@ -129,7 +129,7 @@ fn narrow_dir3(dir:Vector3)->Planar64Vec3{ dir>>(big-MAX_BITS) }else{ dir - }.narrow_1().unwrap() + }.narrow_64().unwrap() } fn reduce1>( diff --git a/engine/physics/src/model.rs b/engine/physics/src/model.rs index a860e944..624ec054 100644 --- a/engine/physics/src/model.rs +++ b/engine/physics/src/model.rs @@ -350,8 +350,8 @@ impl TryFrom<&model::Mesh> for PhysicsMesh{ } //assume face hash is stable, and there are no flush faces... let face=Face{ - normal:(normal/len as i64).divide().narrow_1().unwrap(), - dot:(dot/(len*len) as i64).narrow_1().unwrap(), + normal:(normal/len as i64).divide().narrow_64().unwrap(), + dot:(dot/(len*len) as i64).narrow_64().unwrap(), }; let face_id=*face_id_from_face.entry(face).or_insert_with(||{ let face_id=MeshFaceId::new(faces.len() as u32); diff --git a/engine/physics/src/physics.rs b/engine/physics/src/physics.rs index b11239b5..31f70b3e 100644 --- a/engine/physics/src/physics.rs +++ b/engine/physics/src/physics.rs @@ -428,7 +428,7 @@ impl HitboxMesh{ let transform=PhysicsMeshTransform::new(transform); let transformed_mesh=TransformedMesh::new(mesh.complete_mesh_view(),&transform); for vert in transformed_mesh.verts(){ - aabb.grow(vert.narrow_1().unwrap()); + aabb.grow(vert.narrow_64().unwrap()); } Self{ halfsize:aabb.size()>>1, @@ -1118,7 +1118,7 @@ impl PhysicsData{ let mut aabb=aabb::Aabb::default(); let transformed_mesh=TransformedMesh::new(view,transform); for v in transformed_mesh.verts(){ - aabb.grow(v.narrow_1().unwrap()); + aabb.grow(v.narrow_64().unwrap()); } (ConvexMeshId{ model_id, diff --git a/lib/bsp_loader/src/brush.rs b/lib/bsp_loader/src/brush.rs index 9e431086..4d536feb 100644 --- a/lib/bsp_loader/src/brush.rs +++ b/lib/bsp_loader/src/brush.rs @@ -138,7 +138,7 @@ fn planes_to_faces(face_list:std::collections::HashSet)->ResultSelf{ Self{ - halfsize:((int3(33,73,33)>>1)*VALVE_SCALE).narrow_1().unwrap(), + halfsize:((int3(33,73,33)>>1)*VALVE_SCALE).narrow_64().unwrap(), mesh:HitboxMesh::Box, } } @@ -538,11 +538,11 @@ impl StyleModifiers{ tick_rate:Ratio64::new(100,AbsoluteTime::ONE_SECOND.get() as u64).unwrap(), }), jump:Some(JumpSettings{ - impulse:JumpImpulse::Height((int(52)*VALVE_SCALE).narrow_1().unwrap()), + impulse:JumpImpulse::Height((int(52)*VALVE_SCALE).narrow_64().unwrap()), calculation:JumpCalculation::JumpThenBoost, limit_minimum:true, }), - gravity:(int3(0,-800,0)*VALVE_SCALE).narrow_1().unwrap(), + gravity:(int3(0,-800,0)*VALVE_SCALE).narrow_64().unwrap(), mass:int(1), rocket:None, walk:Some(WalkSettings{ @@ -565,7 +565,7 @@ impl StyleModifiers{ magnitude:int(12),//? }), hitbox:Hitbox::source(), - camera_offset:((int3(0,64,0)-(int3(0,73,0)>>1))*VALVE_SCALE).narrow_1().unwrap(), + camera_offset:((int3(0,64,0)-(int3(0,73,0)>>1))*VALVE_SCALE).narrow_64().unwrap(), } } pub fn source_surf()->Self{ @@ -574,16 +574,16 @@ impl StyleModifiers{ controls_mask_state:Controls::all(), strafe:Some(StrafeSettings{ enable:ControlsActivation::full_2d(), - air_accel_limit:Some((int(150)*66*VALVE_SCALE).narrow_1().unwrap()), + air_accel_limit:Some((int(150)*66*VALVE_SCALE).narrow_64().unwrap()), mv:Planar64::raw(30<<28), tick_rate:Ratio64::new(66,AbsoluteTime::ONE_SECOND.get() as u64).unwrap(), }), jump:Some(JumpSettings{ - impulse:JumpImpulse::Height((int(52)*VALVE_SCALE).narrow_1().unwrap()), + impulse:JumpImpulse::Height((int(52)*VALVE_SCALE).narrow_64().unwrap()), calculation:JumpCalculation::JumpThenBoost, limit_minimum:true, }), - gravity:(int3(0,-800,0)*VALVE_SCALE).narrow_1().unwrap(), + gravity:(int3(0,-800,0)*VALVE_SCALE).narrow_64().unwrap(), mass:int(1), rocket:None, walk:Some(WalkSettings{ @@ -606,7 +606,7 @@ impl StyleModifiers{ magnitude:int(12),//? }), hitbox:Hitbox::source(), - camera_offset:((int3(0,64,0)-(int3(0,73,0)>>1))*VALVE_SCALE).narrow_1().unwrap(), + camera_offset:((int3(0,64,0)-(int3(0,73,0)>>1))*VALVE_SCALE).narrow_64().unwrap(), } } } diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 67e713a4..9b2ce4d8 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -142,8 +142,8 @@ fn test_wrap(){ } #[test] fn test_narrow(){ - assert_eq!(Ok(I32F32::ONE),I256F256::ONE.narrow_1()); - assert_eq!(Ok(I32F32::NEG_ONE),I256F256::NEG_ONE.narrow_1()); + assert_eq!(Ok(I32F32::ONE),I256F256::ONE.narrow_64()); + assert_eq!(Ok(I32F32::NEG_ONE),I256F256::NEG_ONE.narrow_64()); } #[test] fn test_widen(){ diff --git a/lib/rbx_loader/src/rbx.rs b/lib/rbx_loader/src/rbx.rs index 4db84acd..9974d015 100644 --- a/lib/rbx_loader/src/rbx.rs +++ b/lib/rbx_loader/src/rbx.rs @@ -31,11 +31,11 @@ fn planar64_affine3_from_roblox(cf:&rbx_dom_weak::types::CFrame,size:&rbx_dom_we Ok(Planar64Affine3::new( Planar64Mat3::from_cols([ (vec3::try_from_f32_array([cf.orientation.x.x,cf.orientation.y.x,cf.orientation.z.x])? - *integer::try_from_f32(size.x/2.0)?).narrow_1().unwrap(),//.map_err(Planar64ConvertError::Narrow)? + *integer::try_from_f32(size.x/2.0)?).narrow_64().unwrap(),//.map_err(Planar64ConvertError::Narrow)? (vec3::try_from_f32_array([cf.orientation.x.y,cf.orientation.y.y,cf.orientation.z.y])? - *integer::try_from_f32(size.y/2.0)?).narrow_1().unwrap(),//.map_err(Planar64ConvertError::Narrow)? + *integer::try_from_f32(size.y/2.0)?).narrow_64().unwrap(),//.map_err(Planar64ConvertError::Narrow)? (vec3::try_from_f32_array([cf.orientation.x.z,cf.orientation.y.z,cf.orientation.z.z])? - *integer::try_from_f32(size.z/2.0)?).narrow_1().unwrap(),//.map_err(Planar64ConvertError::Narrow)? + *integer::try_from_f32(size.z/2.0)?).narrow_64().unwrap(),//.map_err(Planar64ConvertError::Narrow)? ]), vec3::try_from_f32_array([cf.position.x,cf.position.y,cf.position.z])? )) @@ -909,13 +909,13 @@ impl PartialMap1<'_>{ model.mesh=mesh; // avoid devide by zero but introduce more edge cases. not sure what the correct thing to do here is. if mesh_size.x!=integer::Fixed::ZERO{ - model.transform.matrix3.x_axis=(model.transform.matrix3.x_axis*2/mesh_size.x).divide().narrow_1().unwrap(); + model.transform.matrix3.x_axis=(model.transform.matrix3.x_axis*2/mesh_size.x).divide().narrow_64().unwrap(); } if mesh_size.y!=integer::Fixed::ZERO{ - model.transform.matrix3.y_axis=(model.transform.matrix3.y_axis*2/mesh_size.y).divide().narrow_1().unwrap(); + model.transform.matrix3.y_axis=(model.transform.matrix3.y_axis*2/mesh_size.y).divide().narrow_64().unwrap(); } if mesh_size.z!=integer::Fixed::ZERO{ - model.transform.matrix3.z_axis=(model.transform.matrix3.z_axis*2/mesh_size.z).divide().narrow_1().unwrap(); + model.transform.matrix3.z_axis=(model.transform.matrix3.z_axis*2/mesh_size.z).divide().narrow_64().unwrap(); } Some(model) }).chain(self.deferred_unions_deferred_attributes.into_iter().flat_map(|deferred_union_deferred_attributes|{ @@ -932,13 +932,13 @@ impl PartialMap1<'_>{ model.mesh=mesh; // avoid devide by zero but introduce more edge cases. not sure what the correct thing to do here is. if size.x!=integer::Fixed::ZERO{ - model.transform.matrix3.x_axis=(model.transform.matrix3.x_axis*2/size.x).divide().narrow_1().unwrap(); + model.transform.matrix3.x_axis=(model.transform.matrix3.x_axis*2/size.x).divide().narrow_64().unwrap(); } if size.y!=integer::Fixed::ZERO{ - model.transform.matrix3.y_axis=(model.transform.matrix3.y_axis*2/size.y).divide().narrow_1().unwrap(); + model.transform.matrix3.y_axis=(model.transform.matrix3.y_axis*2/size.y).divide().narrow_64().unwrap(); } if size.z!=integer::Fixed::ZERO{ - model.transform.matrix3.z_axis=(model.transform.matrix3.z_axis*2/size.z).divide().narrow_1().unwrap(); + model.transform.matrix3.z_axis=(model.transform.matrix3.z_axis*2/size.z).divide().narrow_64().unwrap(); } Some(model) })) diff --git a/lib/snf/src/map.rs b/lib/snf/src/map.rs index 833de375..f570be68 100644 --- a/lib/snf/src/map.rs +++ b/lib/snf/src/map.rs @@ -386,7 +386,7 @@ pub fn write_map(mut writer:W,map:strafesnet_common::map::Comple let mesh=map.meshes.get(model.mesh.get() as usize).ok_or(Error::InvalidMeshId(model.mesh))?; let mut aabb=Aabb::default(); for &pos in &mesh.unique_pos{ - aabb.grow(model.transform.transform_point3(pos).narrow_1().unwrap()); + aabb.grow(model.transform.transform_point3(pos).narrow_64().unwrap()); } Ok(((model::ModelId::new(model_id as u32),model.into()),aabb)) }).collect::,_>>()?; -- 2.49.1 From adc999b4d510ddb17eb5d3cacc879757dca9e7ed Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:29:13 -0700 Subject: [PATCH 16/86] widen --- lib/fixed_wide/src/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 9b2ce4d8..d4a71975 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -147,8 +147,8 @@ fn test_narrow(){ } #[test] fn test_widen(){ - assert_eq!(I32F32::ONE.widen_8(),I256F256::ONE); - assert_eq!(I32F32::NEG_ONE.widen_8(),I256F256::NEG_ONE); + assert_eq!(I32F32::ONE.widen_512(),I256F256::ONE); + assert_eq!(I32F32::NEG_ONE.widen_512(),I256F256::NEG_ONE); } #[test] fn test_clamp(){ -- 2.49.1 From 8ba1175ac1bdf0e08c5d58ff394c0bd681236ad8 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:29:19 -0700 Subject: [PATCH 17/86] fix zeroes --- lib/fixed_wide/src/fixed.rs | 2 +- lib/fixed_wide/src/zeroes.rs | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index d582f524..5a9dd5f4 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -1,6 +1,6 @@ use bnum::{Int,cast::As,n}; -const BNUM_DIGIT_WIDTH:usize=8; +pub(crate)const BNUM_DIGIT_WIDTH:usize=8; /// how many bnum 14 digits are there per bnum 13 digit const BNUM_13_COMPAT:usize=64/8; diff --git a/lib/fixed_wide/src/zeroes.rs b/lib/fixed_wide/src/zeroes.rs index 0bde9dd9..79359a40 100644 --- a/lib/fixed_wide/src/zeroes.rs +++ b/lib/fixed_wide/src/zeroes.rs @@ -1,10 +1,11 @@ use crate::fixed::Fixed; +use crate::fixed::BNUM_DIGIT_WIDTH; use arrayvec::ArrayVec; use std::cmp::Ordering; macro_rules! impl_zeroes{ ($n:expr)=>{ - impl Fixed<$n,{$n*32}>{ + impl Fixed<{$n/BNUM_DIGIT_WIDTH},{$n>>1}>{ #[inline] pub fn zeroes2(a0:Self,a1:Self,a2:Self)->ArrayVec<::Output,2>{ let a2pos=match a2.cmp(&Self::ZERO){ @@ -12,7 +13,7 @@ macro_rules! impl_zeroes{ Ordering::Equal=>return ArrayVec::from_iter(Self::zeroes1(a0,a1).into_iter()), Ordering::Less=>false, }; - let radicand=a1*a1-a2*a0*4; + let radicand=a1*a1-(a2*a0)<<2; match radicand.cmp(&::Output::ZERO){ Ordering::Greater=>{ // using wrap because sqrt always halves the number of leading digits. @@ -22,14 +23,14 @@ macro_rules! impl_zeroes{ } //sort roots ascending and avoid taking the difference of large numbers let zeroes=match (a2pos,Self::ZERO[(-a1-planar_radicand)/(a2*2),(a0*2)/(-a1-planar_radicand)], - (true, false)=>[(a0*2)/(-a1+planar_radicand),(-a1+planar_radicand)/(a2*2)], - (false,true )=>[(a0*2)/(-a1-planar_radicand),(-a1-planar_radicand)/(a2*2)], - (false,false)=>[(-a1+planar_radicand)/(a2*2),(a0*2)/(-a1+planar_radicand)], + (true, true )=>[(-a1-planar_radicand)/(a2>>1),(a0>>1)/(-a1-planar_radicand)], + (true, false)=>[(a0>>1)/(-a1+planar_radicand),(-a1+planar_radicand)/(a2>>1)], + (false,true )=>[(a0>>1)/(-a1-planar_radicand),(-a1-planar_radicand)/(a2>>1)], + (false,false)=>[(-a1+planar_radicand)/(a2>>1),(a0>>1)/(-a1+planar_radicand)], }; ArrayVec::from_iter(zeroes) }, - Ordering::Equal=>ArrayVec::from_iter([(a1)/(a2*-2)]), + Ordering::Equal=>ArrayVec::from_iter([(a1)/(-a2>>1)]), Ordering::Less=>ArrayVec::new_const(), } } @@ -44,10 +45,10 @@ macro_rules! impl_zeroes{ } }; } -impl_zeroes!(1); -impl_zeroes!(2); -impl_zeroes!(3); -impl_zeroes!(4); +impl_zeroes!(64); +impl_zeroes!(128); +impl_zeroes!(192); +impl_zeroes!(256); //sqrt doubles twice! //impl_zeroes!(5); //impl_zeroes!(6); -- 2.49.1 From f352462f7b5dd8c17a4072c1d3206d9bdeb3eb0a Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:36:55 -0700 Subject: [PATCH 18/86] no --- lib/fixed_wide/src/fixed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 5a9dd5f4..7b4e7bbc 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -112,7 +112,7 @@ impl Fixed<8,F>{ } #[inline] pub const fn to_raw(self)->i64{ - i64::from_ne_bytes(self.to_bits().to_bytes()) + i64::from_le_bytes(self.to_bits().to_bytes()) } } -- 2.49.1 From e80355a3a5dea76b7ad82ed7b6adaf7078bc7c2b Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:37:05 -0700 Subject: [PATCH 19/86] fix tests --- lib/fixed_wide/src/tests.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index d4a71975..eb3319db 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -1,4 +1,5 @@ use crate::types::I32F32; +use crate::types::I96F96; use crate::types::I256F256; #[test] @@ -112,9 +113,9 @@ fn test_wide_div(){ let ab=a.wide_div_64_64(b); assert_eq!(ab,crate::types::I64F64::ONE*2); let wab=wide_a.wide_div_128_64(b); - assert_eq!(wab,crate::fixed::Fixed::<3,96>::ONE*2); + assert_eq!(wab,I96F96::ONE*2); let awb=a.wide_div_64_128(wide_b); - assert_eq!(awb,crate::fixed::Fixed::<3,96>::ONE*2); + assert_eq!(awb,I96F96::ONE*2); } #[test] @@ -173,12 +174,11 @@ fn test_sqrt_low(){ } fn find_equiv_sqrt_via_f64(n:I32F32)->I32F32{ //GIMME THEM BITS BOY - let &[bits]=n.to_bits().to_bits().digits(); - let ibits=bits as i64; + let ibits=i64::from_le_bytes(n.to_bits().to_bytes()); let f=(ibits as f64)/((1u64<<32) as f64); let f_ans=f.sqrt(); - let i=(f_ans*((1u64<<32) as f64)) as i64; - let r=I32F32::from_bits(bnum::BInt::<1>::from(i)); + let i=(f_ans*((1u64<<32) as f64)) as u64; + let r=I32F32::from_u64(i); //mimic the behaviour of the algorithm, //return the result if it truncates to the exact answer if (r+I32F32::EPSILON).wide_mul_64_64(r+I32F32::EPSILON)==n.wide_mul_64_64(I32F32::ONE){ -- 2.49.1 From b8aada7f66340d9fdf7a1d9fc92b73b5e5add402 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:37:12 -0700 Subject: [PATCH 20/86] fix macros --- lib/fixed_wide/src/fixed.rs | 92 ++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 7b4e7bbc..bf352906 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -325,14 +325,14 @@ impl core::fmt::Display for Fixed{ } macro_rules! impl_additive_operator { - ( $struct: ident, $trait: ident, $method: ident, $output: ty ) => { - impl $struct{ + ( $trait: ident, $method: ident, $output: ty ) => { + impl Fixed{ #[inline] pub const fn $method(self, other: Self) -> Self { Self::from_bits(self.bits.$method(other.bits)) } } - impl core::ops::$trait for $struct{ + impl core::ops::$trait for Fixed{ type Output = $output; #[inline] fn $method(self, other: Self) -> Self::Output { @@ -342,8 +342,8 @@ macro_rules! impl_additive_operator { }; } macro_rules! impl_additive_assign_operator { - ( $struct: ident, $trait: ident, $method: ident ) => { - impl core::ops::$trait for $struct{ + ( $trait: ident, $method: ident ) => { + impl core::ops::$trait for Fixed{ #[inline] fn $method(&mut self, other: Self) { self.bits.$method(other.bits); @@ -353,28 +353,28 @@ macro_rules! impl_additive_assign_operator { } // Impl arithmetic pperators -impl_additive_assign_operator!( Fixed, AddAssign, add_assign ); -impl_additive_operator!( Fixed, Add, add, Self ); -impl_additive_assign_operator!( Fixed, SubAssign, sub_assign ); -impl_additive_operator!( Fixed, Sub, sub, Self ); -impl_additive_assign_operator!( Fixed, RemAssign, rem_assign ); -impl_additive_operator!( Fixed, Rem, rem, Self ); +impl_additive_assign_operator!( AddAssign, add_assign ); +impl_additive_operator!( Add, add, Self ); +impl_additive_assign_operator!( SubAssign, sub_assign ); +impl_additive_operator!( Sub, sub, Self ); +impl_additive_assign_operator!( RemAssign, rem_assign ); +impl_additive_operator!( Rem, rem, Self ); // Impl bitwise operators -impl_additive_assign_operator!( Fixed, BitAndAssign, bitand_assign ); -impl_additive_operator!( Fixed, BitAnd, bitand, Self ); -impl_additive_assign_operator!( Fixed, BitOrAssign, bitor_assign ); -impl_additive_operator!( Fixed, BitOr, bitor, Self ); -impl_additive_assign_operator!( Fixed, BitXorAssign, bitxor_assign ); -impl_additive_operator!( Fixed, BitXor, bitxor, Self ); +impl_additive_assign_operator!( BitAndAssign, bitand_assign ); +impl_additive_operator!( BitAnd, bitand, Self ); +impl_additive_assign_operator!( BitOrAssign, bitor_assign ); +impl_additive_operator!( BitOr, bitor, Self ); +impl_additive_assign_operator!( BitXorAssign, bitxor_assign ); +impl_additive_operator!( BitXor, bitxor, Self ); // non-wide operators. The result is the same width as the inputs. // This macro is not used in the default configuration. #[expect(unused_macros)] macro_rules! impl_multiplicative_operator_not_const_generic { - ( ($struct: ident, $trait: ident, $method: ident, $output: ty ), $width:expr ) => { - impl core::ops::$trait for $struct<$width,F>{ + ( ($trait: ident, $method: ident, $output: ty ), $width:expr ) => { + impl core::ops::$trait for Fixed<{$width/BNUM_DIGIT_WIDTH},F>{ type Output = $output; #[inline] fn $method(self, other: Self) -> Self::Output { @@ -386,8 +386,8 @@ macro_rules! impl_multiplicative_operator_not_const_generic { }; } macro_rules! impl_multiplicative_assign_operator_not_const_generic { - ( ($struct: ident, $trait: ident, $method: ident, $non_assign_method: ident ), $width:expr ) => { - impl core::ops::$trait for $struct<$width,F>{ + ( ($trait: ident, $method: ident, $non_assign_method: ident ), $width:expr ) => { + impl core::ops::$trait for Fixed<{$width/BNUM_DIGIT_WIDTH},F>{ #[inline] fn $method(&mut self, other: Self) { paste::item!{ @@ -399,8 +399,8 @@ macro_rules! impl_multiplicative_assign_operator_not_const_generic { } macro_rules! impl_multiply_operator_not_const_generic { - ( ($struct: ident, $trait: ident, $method: ident, $output: ty ), $width:expr ) => { - impl $struct<$width,F>{ + ( ($trait: ident, $method: ident, $output: ty ), $width:expr ) => { + impl Fixed<{$width/BNUM_DIGIT_WIDTH},F>{ paste::item!{ #[inline] pub fn [](self, rhs: Self) -> Self { @@ -427,8 +427,8 @@ macro_rules! impl_multiply_operator_not_const_generic { } } macro_rules! impl_divide_operator_not_const_generic { - ( ($struct: ident, $trait: ident, $method: ident, $output: ty ), $width:expr ) => { - impl $struct<$width,F>{ + ( ($trait: ident, $method: ident, $output: ty ), $width:expr ) => { + impl Fixed<{$width/BNUM_DIGIT_WIDTH},F>{ paste::item!{ #[inline] pub fn [](self,other:Self)->Self{ @@ -442,7 +442,7 @@ macro_rules! impl_divide_operator_not_const_generic { #[cfg(all(not(feature="wide-mul"),not(feature="deferred-division")))] impl_multiplicative_operator_not_const_generic!(($struct, $trait, $method, $output ), $width); #[cfg(all(not(feature="wide-mul"),feature="deferred-division"))] - impl ratio_ops::ratio::Divide for $struct<$width,F>{ + impl ratio_ops::ratio::Divide for Fixed<{$width/BNUM_DIGIT_WIDTH},F>{ type Output = $output; #[inline] fn divide(self, other: Self) -> Self::Output { @@ -455,8 +455,8 @@ macro_rules! impl_divide_operator_not_const_generic { } macro_rules! impl_multiplicative_operator { - ( $struct: ident, $trait: ident, $method: ident, $inner_method: ident, $output: ty ) => { - impl core::ops::$trait for $struct + ( $trait: ident, $method: ident, $inner_method: ident, $output: ty ) => { + impl core::ops::$trait for Fixed where Int:::From+core::ops::$trait, { @@ -469,8 +469,8 @@ macro_rules! impl_multiplicative_operator { }; } macro_rules! impl_multiplicative_assign_operator { - ( $struct: ident, $trait: ident, $method: ident, $not_assign_method: ident ) => { - impl core::ops::$trait for $struct + ( $trait: ident, $method: ident, $not_assign_method: ident ) => { + impl core::ops::$trait for Fixed where Int:::From+core::ops::$trait, { @@ -500,14 +500,14 @@ macro_rules! macro_16 { } } -macro_16!( impl_multiplicative_assign_operator_not_const_generic, (Fixed, MulAssign, mul_assign, mul) ); -macro_16!( impl_multiply_operator_not_const_generic, (Fixed, Mul, mul, Self) ); -macro_16!( impl_multiplicative_assign_operator_not_const_generic, (Fixed, DivAssign, div_assign, div_euclid) ); -macro_16!( impl_divide_operator_not_const_generic, (Fixed, Div, div_euclid, Self) ); -impl_multiplicative_assign_operator!( Fixed, MulAssign, mul_assign, mul ); -impl_multiplicative_operator!( Fixed, Mul, mul, mul, Self ); -impl_multiplicative_assign_operator!( Fixed, DivAssign, div_assign, div_euclid ); -impl_multiplicative_operator!( Fixed, Div, div, div_euclid, Self ); +macro_16!( impl_multiplicative_assign_operator_not_const_generic, (MulAssign, mul_assign, mul) ); +macro_16!( impl_multiply_operator_not_const_generic, (Mul, mul, Self) ); +macro_16!( impl_multiplicative_assign_operator_not_const_generic, (DivAssign, div_assign, div_euclid) ); +macro_16!( impl_divide_operator_not_const_generic, (Div, div_euclid, Self) ); +impl_multiplicative_assign_operator!( MulAssign, mul_assign, mul ); +impl_multiplicative_operator!( Mul, mul, mul, Self ); +impl_multiplicative_assign_operator!( DivAssign, div_assign, div_euclid ); +impl_multiplicative_operator!( Div, div, div_euclid, Self ); #[cfg(feature="deferred-division")] impl core::ops::Div> for Fixed{ type Output=ratio_ops::ratio::Ratio,Fixed>; @@ -523,8 +523,8 @@ impl ratio_ops::ratio::Parity for Fixed{ } } macro_rules! impl_shift_operator { - ( $struct: ident, $trait: ident, $method: ident, $output: ty ) => { - impl core::ops::$trait for $struct{ + ( $trait: ident, $method: ident, $output: ty ) => { + impl core::ops::$trait for Fixed{ type Output = $output; #[inline] fn $method(self, other: u32) -> Self::Output { @@ -534,8 +534,8 @@ macro_rules! impl_shift_operator { }; } macro_rules! impl_shift_assign_operator { - ( $struct: ident, $trait: ident, $method: ident ) => { - impl core::ops::$trait for $struct{ + ( $trait: ident, $method: ident ) => { + impl core::ops::$trait for Fixed{ #[inline] fn $method(&mut self, other: u32) { self.bits.$method(other); @@ -543,10 +543,10 @@ macro_rules! impl_shift_assign_operator { } }; } -impl_shift_assign_operator!( Fixed, ShlAssign, shl_assign ); -impl_shift_operator!( Fixed, Shl, shl, Self ); -impl_shift_assign_operator!( Fixed, ShrAssign, shr_assign ); -impl_shift_operator!( Fixed, Shr, shr, Self ); +impl_shift_assign_operator!( ShlAssign, shl_assign ); +impl_shift_operator!( Shl, shl, Self ); +impl_shift_assign_operator!( ShrAssign, shr_assign ); +impl_shift_operator!( Shr, shr, Self ); // wide operators. The result width is the sum of the input widths, i.e. none of the multiplication -- 2.49.1 From 7a9961d04e35f88fe0304cd686b5aead164ec666 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:38:18 -0700 Subject: [PATCH 21/86] oops --- lib/fixed_wide/src/fixed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index bf352906..506de474 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -405,7 +405,7 @@ macro_rules! impl_multiply_operator_not_const_generic { #[inline] pub fn [](self, rhs: Self) -> Self { let (low,high)=self.bits.unsigned_abs().widening_mul(rhs.bits.unsigned_abs()); - let out:Int::<{$width*2}>=unsafe{core::mem::transmute([low,high])}; + let out:Int::<{$width*2/BNUM_DIGIT_WIDTH}>=unsafe{core::mem::transmute([low,high])}; if self.is_negative()==rhs.is_negative(){ Self::from_bits(out.shr(F as u32).as_()) }else{ -- 2.49.1 From 68a3a1c93f7e5922221940dd98b9e549ccbcb625 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:38:53 -0700 Subject: [PATCH 22/86] n --- lib/fixed_wide/src/fixed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 506de474..8f1eb6f8 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -303,7 +303,7 @@ impl core::fmt::Debug for Fixed{ #[inline] fn fmt(&self,f:&mut core::fmt::Formatter)->Result<(),core::fmt::Error>{ let integral=self.as_bits().unsigned_abs()>>F; - let fractional=self.as_bits().unsigned_abs()&((bnum::Uint::::ONE<::ONE); + let fractional=self.as_bits().unsigned_abs()&((n!(1)<>2; if self.is_negative(){ core::write!(f,"-")?; -- 2.49.1 From d18347f620bb9806659b00b54a1f6e365f952db1 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:40:08 -0700 Subject: [PATCH 23/86] widen_* --- engine/physics/src/face_crawler.rs | 4 ++-- engine/physics/src/minimum_difference.rs | 2 +- engine/physics/src/minkowski.rs | 6 +++--- engine/physics/src/model.rs | 2 +- lib/bsp_loader/src/brush.rs | 8 ++++---- lib/common/src/gameplay_style.rs | 14 +++++++------- lib/common/src/integer.rs | 2 +- lib/fixed_wide/src/tests.rs | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/engine/physics/src/face_crawler.rs b/engine/physics/src/face_crawler.rs index dc170a77..023929b6 100644 --- a/engine/physics/src/face_crawler.rs +++ b/engine/physics/src/face_crawler.rs @@ -142,7 +142,7 @@ impl,Offset=I128F128,Position=Planar64Vec3, let n=edge_n*(1-2*(i as i64)); for dt in I64F64::zeroes2((n.dot(trajectory.position-mesh.vert(vert_id)))*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ - let dt=Ratio::new(dt.num.widen_4(),dt.den.widen_4()); + let dt=Ratio::new(dt.num.widen_256(),dt.den.widen_256()); upper_bound=Bound::Included(dt); best_transition=Transition::Next(FEV::Vert(vert_id),dt); break; @@ -158,7 +158,7 @@ impl,Offset=I128F128,Position=Planar64Vec3, let n=-mesh.directed_edge_n(directed_edge_id); for dt in I64F64::zeroes2((n.dot(trajectory.position-mesh.vert(vert_id)))*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ - let dt=Ratio::new(dt.num.widen_4(),dt.den.widen_4()); + let dt=Ratio::new(dt.num.widen_256(),dt.den.widen_256()); upper_bound=Bound::Included(dt); best_transition=Transition::Next(FEV::Edge(directed_edge_id.as_undirected()),dt); break; diff --git a/engine/physics/src/minimum_difference.rs b/engine/physics/src/minimum_difference.rs index f9070093..68a8718e 100644 --- a/engine/physics/src/minimum_difference.rs +++ b/engine/physics/src/minimum_difference.rs @@ -601,7 +601,7 @@ impl ThickLine{ let dir=p1-p0; // Allow ~ 2*sqrt(3) units of thickness on the plane // This is to account for the variance of two voxels across the longest diagonal - let epsilon=(dir.length_squared()*(Planar64::EPSILON*3)).widen_4(); + let epsilon=(dir.length_squared()*(Planar64::EPSILON*3)).widen_256(); Self{point,dir,epsilon} } } diff --git a/engine/physics/src/minkowski.rs b/engine/physics/src/minkowski.rs index a25ed6f5..c0d0ca04 100644 --- a/engine/physics/src/minkowski.rs +++ b/engine/physics/src/minkowski.rs @@ -178,7 +178,7 @@ impl MeshQuery for MinkowskiMesh<'_>{ let n=edge0_n.cross(edge1_n); let e0d=n.dot(self.mesh0.vert(e0v0)+self.mesh0.vert(e0v1)); let e1d=n.dot(self.mesh1.vert(e1v0)+self.mesh1.vert(e1v1)); - ((n*(parity as i64*4-2)).widen_3(),((e0d-e1d)*(parity as i64*2-1)).widen_4()) + ((n*(parity as i64*4-2)).widen_192(),((e0d-e1d)*(parity as i64*2-1)).widen_256()) }, MinkowskiFace::FaceVert(f0,v1)=>{ let (n,d)=self.mesh0.face_nd(f0); @@ -404,6 +404,6 @@ fn is_empty_volume(normals:&[Vector3])->bool{ #[test] fn test_is_empty_volume(){ use strafesnet_common::integer::vec3; - assert!(!is_empty_volume(&[vec3::X.widen_3(),vec3::Y.widen_3(),vec3::Z.widen_3()])); - assert!(is_empty_volume(&[vec3::X.widen_3(),vec3::Y.widen_3(),vec3::Z.widen_3(),vec3::NEG_X.widen_3()])); + assert!(!is_empty_volume(&[vec3::X.widen_192(),vec3::Y.widen_192(),vec3::Z.widen_192()])); + assert!(is_empty_volume(&[vec3::X.widen_192(),vec3::Y.widen_192(),vec3::Z.widen_192(),vec3::NEG_X.widen_192()])); } diff --git a/engine/physics/src/model.rs b/engine/physics/src/model.rs index 624ec054..1a1fa0ef 100644 --- a/engine/physics/src/model.rs +++ b/engine/physics/src/model.rs @@ -566,5 +566,5 @@ impl MeshTopology for TransformedMesh<'_>{ pub type GigaTime=Ratio; pub fn into_giga_time(time:Time,relative_to:Time)->GigaTime{ let r=(time-relative_to).to_ratio(); - Ratio::new(r.num.widen_4(),r.den.widen_4()) + Ratio::new(r.num.widen_256(),r.den.widen_256()) } diff --git a/lib/bsp_loader/src/brush.rs b/lib/bsp_loader/src/brush.rs index 4d536feb..4f5283eb 100644 --- a/lib/bsp_loader/src/brush.rs +++ b/lib/bsp_loader/src/brush.rs @@ -82,12 +82,12 @@ fn planes_to_faces(face_list:std::collections::HashSet)->Result)->Result)->Resultvelocity+(jump_dir*jump_speed/jump_dir.length()).divide().clamp_64(), @@ -126,7 +126,7 @@ impl JumpSettings{ None=>rel_velocity, }; let j=boost_vel.dot(jump_dir); - let js=jump_speed.widen_2(); + let js=jump_speed.widen_128(); if jrel_velocity, }; let j=boost_vel.dot(jump_dir); - let js=jump_speed.widen_2(); + let js=jump_speed.widen_128(); if jrel_velocity, }; let boost_dot=boost_vel.dot(jump_dir); - let js=jump_speed.widen_2(); + let js=jump_speed.widen_128(); if boost_dotOption{ let d=velocity.dot(control_dir); - let mv=self.mv.widen_2(); + let mv=self.mv.widen_128(); match dSome(velocity+(control_dir*self.air_accel_limit.map_or(mv-d,|limit|limit.widen_2().min(mv-d))).wrap_64()), + true=>Some(velocity+(control_dir*self.air_accel_limit.map_or(mv-d,|limit|limit.widen_128().min(mv-d))).wrap_64()), false=>None, } } @@ -374,7 +374,7 @@ impl LadderSettings{ }else{ control_dir=Planar64Vec3::new([Planar64::ZERO,-mm.clamp_64(),Planar64::ZERO]); } - dd=(normal.y*normal.y).widen_4(); + dd=(normal.y*normal.y).widen_256(); } //n=d if you are standing on top of a ladder and press E. //two fixes: diff --git a/lib/common/src/integer.rs b/lib/common/src/integer.rs index bdf3f1f5..70f95cd2 100644 --- a/lib/common/src/integer.rs +++ b/lib/common/src/integer.rs @@ -726,7 +726,7 @@ impl Planar64Affine3{ } #[inline] pub fn transform_point3(&self,point:Planar64Vec3)->vec3::Vector3>{ - self.translation.widen_2()+self.matrix3*point + self.translation.widen_128()+self.matrix3*point } } impl Into for Planar64Affine3{ diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index eb3319db..cad417c3 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -62,7 +62,7 @@ fn from_f32(){ let b:Result=Into::::into(I32F32::MIN).try_into(); assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Overflow)); //16 is within the 24 bits of float precision - let b:Result=Into::::into(-I32F32::MIN.widen_2()).try_into(); + let b:Result=Into::::into(-I32F32::MIN.widen_128()).try_into(); assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Overflow)); let b:Result=f32::MIN_POSITIVE.try_into(); assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Underflow)); -- 2.49.1 From 2c42027d8bcab52dfca60504828254e401af5ff2 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 10:48:04 -0700 Subject: [PATCH 24/86] the float convert plan --- lib/fixed_wide/src/fixed.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 8f1eb6f8..3068dd12 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -151,13 +151,6 @@ impl std::iter::Sum for Fixed{ } } -const fn signed_shift(lhs:u8,rhs:i32)->u8{ - if rhs.is_negative(){ - lhs>>-rhs - }else{ - lhs< { impl Into<$output> for Fixed{ @@ -184,6 +177,8 @@ macro_rules! impl_into_float { let take_bits=most_significant_bit-(digit_index< Date: Thu, 19 Mar 2026 12:01:15 -0700 Subject: [PATCH 25/86] use constant --- lib/fixed_wide/src/types.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/fixed_wide/src/types.rs b/lib/fixed_wide/src/types.rs index c170dbf0..e8423cc8 100644 --- a/lib/fixed_wide/src/types.rs +++ b/lib/fixed_wide/src/types.rs @@ -1,5 +1,6 @@ -pub type I32F32=crate::fixed::Fixed<8,32>; -pub type I64F64=crate::fixed::Fixed<16,64>; -pub type I96F96=crate::fixed::Fixed<24,96>; -pub type I128F128=crate::fixed::Fixed<32,128>; -pub type I256F256=crate::fixed::Fixed<64,256>; +use crate::fixed::BNUM_DIGIT_WIDTH; +pub type I32F32=crate::fixed::Fixed<{64/BNUM_DIGIT_WIDTH},32>; +pub type I64F64=crate::fixed::Fixed<{128/BNUM_DIGIT_WIDTH},64>; +pub type I96F96=crate::fixed::Fixed<{192/BNUM_DIGIT_WIDTH},96>; +pub type I128F128=crate::fixed::Fixed<{256/BNUM_DIGIT_WIDTH},128>; +pub type I256F256=crate::fixed::Fixed<{512/BNUM_DIGIT_WIDTH},256>; -- 2.49.1 From ed6b0f2539b66a4e16385f38053c1fa72debd1d9 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 12:02:16 -0700 Subject: [PATCH 26/86] rename constants --- engine/physics/src/face_crawler.rs | 20 +-- engine/physics/src/minimum_difference.rs | 14 +- engine/physics/src/minkowski.rs | 10 +- engine/physics/src/model.rs | 14 +- engine/physics/src/push_solve.rs | 4 +- lib/common/src/integer.rs | 8 +- lib/fixed_wide/src/tests.rs | 170 +++++++++++------------ lib/fixed_wide/src/types.rs | 10 +- lib/linear_ops/src/tests/fixed_wide.rs | 6 +- 9 files changed, 128 insertions(+), 128 deletions(-) diff --git a/engine/physics/src/face_crawler.rs b/engine/physics/src/face_crawler.rs index 023929b6..1fec10d2 100644 --- a/engine/physics/src/face_crawler.rs +++ b/engine/physics/src/face_crawler.rs @@ -1,5 +1,5 @@ use crate::model::{into_giga_time,GigaTime}; -use strafesnet_common::integer::fixed_types::{I32F32,I64F64,I128F128}; +use strafesnet_common::integer::fixed_types::{F64_32,F128_64,F256_128}; use strafesnet_common::integer::vec3::Vector3; use strafesnet_common::integer::{Fixed,Ratio,Planar64Vec3}; use crate::physics::{Time,Trajectory}; @@ -67,16 +67,16 @@ where } } -impl,Offset=I128F128,Position=Planar64Vec3,Direction=Planar64Vec3>> FEV +impl,Offset=F256_128,Position=Planar64Vec3,Direction=Planar64Vec3>> FEV where // This is hardcoded for MinkowskiMesh lol M::Face:Copy, M::Edge:Copy, M::DirectedEdge:Copy, M::Vert:Copy, - F:core::ops::Mul, - >::Output:core::iter::Sum, - M::Offset:core::ops::Sub<>::Output>, + F:core::ops::Mul, + >::Output:core::iter::Sum, + M::Offset:core::ops::Sub<>::Output>, { fn next_transition(&self,mesh:&M,trajectory:&Trajectory,lower_bound:Bound,mut upper_bound:Bound)->Transition{ //conflicting derivative means it crosses in the wrong direction. @@ -90,7 +90,7 @@ impl,Offset=I128F128,Position=Planar64Vec3, let (n,d)=mesh.face_nd(face_id); //TODO: use higher precision d value? //use the mesh transform translation instead of baking it into the d value. - for dt in I128F128::zeroes2((n.dot(trajectory.position)-d)*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ + for dt in F256_128::zeroes2((n.dot(trajectory.position)-d)*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ upper_bound=Bound::Included(dt); best_transition=Transition::Hit(face_id,dt); @@ -105,7 +105,7 @@ impl,Offset=I128F128,Position=Planar64Vec3, //WARNING: d is moved out of the *2 block because of adding two vertices! //WARNING: precision is swept under the rug! //wrap for speed - for dt in I128F128::zeroes2(n.dot(trajectory.position*2-(mesh.vert(v0)+mesh.vert(v1))).wrap_256(),n.dot(trajectory.velocity).wrap_256()*2,n.dot(trajectory.acceleration).wrap_256()){ + for dt in F256_128::zeroes2(n.dot(trajectory.position*2-(mesh.vert(v0)+mesh.vert(v1))).wrap_256(),n.dot(trajectory.velocity).wrap_256()*2,n.dot(trajectory.acceleration).wrap_256()){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ upper_bound=Bound::Included(dt); best_transition=Transition::Next(FEV::Edge(directed_edge_id.as_undirected()),dt); @@ -128,7 +128,7 @@ impl,Offset=I128F128,Position=Planar64Vec3, let n=face_n.cross(edge_n)*((i as i64)*2-1); //WARNING yada yada d *2 //wrap for speed - for dt in I128F128::zeroes2(n.dot(delta_pos).wrap_256(),n.dot(trajectory.velocity).wrap_256()*2,n.dot(trajectory.acceleration).wrap_256()){ + for dt in F256_128::zeroes2(n.dot(delta_pos).wrap_256(),n.dot(trajectory.velocity).wrap_256()*2,n.dot(trajectory.acceleration).wrap_256()){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ upper_bound=Bound::Included(dt); best_transition=Transition::Next(FEV::Face(edge_face_id),dt); @@ -140,7 +140,7 @@ impl,Offset=I128F128,Position=Planar64Vec3, for (i,&vert_id) in edge_verts.as_ref().iter().enumerate(){ //vertex normal gets parity from vert index let n=edge_n*(1-2*(i as i64)); - for dt in I64F64::zeroes2((n.dot(trajectory.position-mesh.vert(vert_id)))*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ + for dt in F128_64::zeroes2((n.dot(trajectory.position-mesh.vert(vert_id)))*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ let dt=Ratio::new(dt.num.widen_256(),dt.den.widen_256()); upper_bound=Bound::Included(dt); @@ -156,7 +156,7 @@ impl,Offset=I128F128,Position=Planar64Vec3, mesh.for_each_vert_edge(vert_id,|directed_edge_id|{ //edge is directed away from vertex, but we want the dot product to turn out negative let n=-mesh.directed_edge_n(directed_edge_id); - for dt in I64F64::zeroes2((n.dot(trajectory.position-mesh.vert(vert_id)))*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ + for dt in F128_64::zeroes2((n.dot(trajectory.position-mesh.vert(vert_id)))*2,n.dot(trajectory.velocity)*2,n.dot(trajectory.acceleration)){ if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ let dt=Ratio::new(dt.num.widen_256(),dt.den.widen_256()); upper_bound=Bound::Included(dt); diff --git a/engine/physics/src/minimum_difference.rs b/engine/physics/src/minimum_difference.rs index 68a8718e..a082e1c0 100644 --- a/engine/physics/src/minimum_difference.rs +++ b/engine/physics/src/minimum_difference.rs @@ -1,4 +1,4 @@ -use strafesnet_common::integer::fixed_types::{I64F64,I96F96,I128F128}; +use strafesnet_common::integer::fixed_types::{F128_64,F192_96,F256_128}; use strafesnet_common::integer::vec3; use strafesnet_common::integer::vec3::Vector3; use strafesnet_common::integer::{Fixed,Planar64,Planar64Vec3}; @@ -101,7 +101,7 @@ const fn choose_any_direction()->Planar64Vec3{ vec3::X } -fn narrow_dir2(dir:Vector3)->Planar64Vec3{ +fn narrow_dir2(dir:Vector3)->Planar64Vec3{ if dir==vec3::zero(){ return dir.narrow_64().unwrap(); } @@ -116,7 +116,7 @@ fn narrow_dir2(dir:Vector3)->Planar64Vec3{ dir }.narrow_64().unwrap() } -fn narrow_dir3(dir:Vector3)->Planar64Vec3{ +fn narrow_dir3(dir:Vector3)->Planar64Vec3{ if dir==vec3::zero(){ return dir.narrow_64().unwrap(); } @@ -566,8 +566,8 @@ trait Contains{ // convenience type to check if a point is within some threshold of a plane. struct ThickPlane{ point:Planar64Vec3, - normal:Vector3, - epsilon:I96F96, + normal:Vector3, + epsilon:F192_96, } impl ThickPlane{ fn new>(mesh:&M,[v0,v1,v2]:Simplex<3,M::Vert>)->Self{ @@ -591,7 +591,7 @@ impl Contains for ThickPlane{ struct ThickLine{ point:Planar64Vec3, dir:Planar64Vec3, - epsilon:I128F128, + epsilon:F256_128, } impl ThickLine{ fn new>(mesh:&M,[v0,v1]:Simplex<2,M::Vert>)->Self{ @@ -614,7 +614,7 @@ impl Contains for ThickLine{ struct EVFinder<'a,M,C>{ mesh:&'a M, constraint:C, - best_distance_squared:I64F64, + best_distance_squared:F128_64, } impl,C:Contains> EVFinder<'_,M,C> diff --git a/engine/physics/src/minkowski.rs b/engine/physics/src/minkowski.rs index c0d0ca04..2bb63f96 100644 --- a/engine/physics/src/minkowski.rs +++ b/engine/physics/src/minkowski.rs @@ -1,6 +1,6 @@ use core::ops::{Bound,RangeBounds}; -use strafesnet_common::integer::fixed_types::{I96F96,I128F128}; +use strafesnet_common::integer::fixed_types::{F192_96,F256_128}; use strafesnet_common::integer::vec3::Vector3; use strafesnet_common::integer::{Planar64Vec3,Ratio,Fixed}; use crate::model::into_giga_time; @@ -144,7 +144,7 @@ impl MinkowskiMesh<'_>{ //WARNING! d outside of *2 //WARNING: truncated precision //wrap for speed - for dt in I128F128::zeroes2(((n.dot(trajectory.position))*2-d).wrap_256(),n.dot(trajectory.velocity).wrap_256()*2,n.dot(trajectory.acceleration).wrap_256()){ + for dt in F256_128::zeroes2(((n.dot(trajectory.position))*2-d).wrap_256(),n.dot(trajectory.velocity).wrap_256()*2,n.dot(trajectory.acceleration).wrap_256()){ if low(&start_time,&dt)&&upp(&dt,&best_time)&&n.dot(trajectory.extrapolated_velocity_ratio_dt(dt)).is_negative(){ best_time=Bound::Included(dt); best_edge=Some((directed_edge_id,dt)); @@ -161,8 +161,8 @@ impl MinkowskiMesh<'_>{ impl MeshQuery for MinkowskiMesh<'_>{ type Direction=Planar64Vec3; type Position=Planar64Vec3; - type Normal=Vector3; - type Offset=I128F128; + type Normal=Vector3; + type Offset=F256_128; // TODO: relative d fn face_nd(&self,face_id:MinkowskiFace)->(Self::Normal,Self::Offset){ match face_id{ @@ -377,7 +377,7 @@ impl MeshTopology for MinkowskiMesh<'_>{ } } -fn is_empty_volume(normals:&[Vector3])->bool{ +fn is_empty_volume(normals:&[Vector3])->bool{ let len=normals.len(); for i in 0..len-1{ for j in i+1..len{ diff --git a/engine/physics/src/model.rs b/engine/physics/src/model.rs index 1a1fa0ef..c7ceee12 100644 --- a/engine/physics/src/model.rs +++ b/engine/physics/src/model.rs @@ -1,5 +1,5 @@ use std::collections::{HashSet,HashMap}; -use strafesnet_common::integer::fixed_types::{I64F64,I96F96,I128F128}; +use strafesnet_common::integer::fixed_types::{F128_64,F192_96,F256_128}; use strafesnet_common::integer::vec3::Vector3; use strafesnet_common::model::{self,MeshId,PolygonIter}; use strafesnet_common::integer::{self,vec3,Fixed,Planar64,Planar64Vec3,Ratio}; @@ -462,8 +462,8 @@ impl MeshTopology for PhysicsMeshView<'_>{ #[derive(Debug)] pub struct PhysicsMeshTransform{ pub vertex:integer::Planar64Affine3, - pub normal:integer::mat3::Matrix3, - pub det:I96F96, + pub normal:integer::mat3::Matrix3, + pub det:F192_96, } impl PhysicsMeshTransform{ pub fn new(transform:integer::Planar64Affine3)->Self{ @@ -490,15 +490,15 @@ impl TransformedMesh<'_>{ transform, } } - pub fn verts<'a>(&'a self)->impl Iterator>+'a{ + pub fn verts<'a>(&'a self)->impl Iterator>+'a{ self.view.data.verts.iter().map(|&Vert(pos)|self.transform.vertex.transform_point3(pos)) } } impl MeshQuery for TransformedMesh<'_>{ type Direction=Planar64Vec3; type Position=Planar64Vec3; - type Normal=Vector3; - type Offset=I128F128; + type Normal=Vector3; + type Offset=F256_128; fn face_nd(&self,face_id:SubmeshFaceId)->(Self::Normal,Self::Offset){ let (n,d)=self.view.face_nd(face_id); let transformed_n=self.transform.normal*n; @@ -563,7 +563,7 @@ impl MeshTopology for TransformedMesh<'_>{ } } -pub type GigaTime=Ratio; +pub type GigaTime=Ratio; pub fn into_giga_time(time:Time,relative_to:Time)->GigaTime{ let r=(time-relative_to).to_ratio(); Ratio::new(r.num.widen_256(),r.den.widen_256()) diff --git a/engine/physics/src/push_solve.rs b/engine/physics/src/push_solve.rs index 280350b7..8b902dec 100644 --- a/engine/physics/src/push_solve.rs +++ b/engine/physics/src/push_solve.rs @@ -1,4 +1,4 @@ -use strafesnet_common::integer::fixed_types::I32F32; +use strafesnet_common::integer::fixed_types::F64_32; use strafesnet_common::integer::vec3::{self,Vector3}; use strafesnet_common::integer::{Fixed,Planar64Vec3,Ratio}; use strafesnet_common::ray::Ray; @@ -13,7 +13,7 @@ use strafesnet_common::ray::Ray; type Conts<'a>=arrayvec::ArrayVec<&'a Contact,4>; // hack to allow comparing ratios to zero -const RATIO_ZERO:Ratio=Ratio::new(Fixed::ZERO,Fixed::EPSILON); +const RATIO_ZERO:Ratio=Ratio::new(Fixed::ZERO,Fixed::EPSILON); /// Information about a contact restriction #[derive(Debug,PartialEq)] diff --git a/lib/common/src/integer.rs b/lib/common/src/integer.rs index 70f95cd2..229da3c3 100644 --- a/lib/common/src/integer.rs +++ b/lib/common/src/integer.rs @@ -5,7 +5,7 @@ pub mod fixed_types{ pub use fixed_wide::types::*; } -use fixed_wide::types::{I32F32,I64F64}; +use fixed_wide::types::{F64_32,F128_64}; //integer units @@ -197,13 +197,13 @@ mod test_time{ #[test] fn time_squared(){ let a=Time::from_secs(2); - assert_eq!(a*a,Ratio::new(I64F64::from_u64(1_000_000_000u64.pow(2))*4,I64F64::from_u64(1_000_000_000u64.pow(2)))); + assert_eq!(a*a,Ratio::new(F128_64::from_u64(1_000_000_000u64.pow(2))*4,F128_64::from_u64(1_000_000_000u64.pow(2)))); } #[test] fn time_times_planar64(){ let a=Time::from_secs(2); let b=Planar64::from(2); - assert_eq!(b*a,Ratio::new(I64F64::from_u64(1_000_000_000*(1<<32))<<2,I32F32::from_u64(1_000_000_000))); + assert_eq!(b*a,Ratio::new(F128_64::from_u64(1_000_000_000*(1<<32))<<2,F64_32::from_u64(1_000_000_000))); } } @@ -604,7 +604,7 @@ impl TryFrom<[f32;3]> for Unit32Vec3{ */ pub type Planar64TryFromFloatError=FixedFromFloatError; -pub type Planar64=fixed_wide::types::I32F32; +pub type Planar64=fixed_wide::types::F64_32; pub type Planar64Vec3=linear_ops::types::Vector3; pub type Planar64Mat3=linear_ops::types::Matrix3; pub mod vec3{ diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index cad417c3..8575d672 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -1,70 +1,70 @@ -use crate::types::I32F32; -use crate::types::I96F96; -use crate::types::I256F256; +use crate::types::F64_32; +use crate::types::F192_96; +use crate::types::F512_256; #[test] fn you_can_add_numbers(){ - let a=I256F256::from((3i128*2).pow(4)); - assert_eq!(a+a,I256F256::from((3i128*2).pow(4)*2)); + let a=F512_256::from((3i128*2).pow(4)); + assert_eq!(a+a,F512_256::from((3i128*2).pow(4)*2)); } #[test] fn to_f32(){ - let a=I256F256::from(1)>>2; + let a=F512_256::from(1)>>2; let f:f32=a.into(); assert_eq!(f,0.25f32); let f:f32=(-a).into(); assert_eq!(f,-0.25f32); - let a=I256F256::from(0); + let a=F512_256::from(0); let f:f32=(-a).into(); assert_eq!(f,0f32); - let a=I256F256::from(237946589723468975i64)<<16; + let a=F512_256::from(237946589723468975i64)<<16; let f:f32=a.into(); assert_eq!(f,237946589723468975f32*2.0f32.powi(16)); } #[test] fn to_f64(){ - let a=I256F256::from(1)>>2; + let a=F512_256::from(1)>>2; let f:f64=a.into(); assert_eq!(f,0.25f64); let f:f64=(-a).into(); assert_eq!(f,-0.25f64); - let a=I256F256::from(0); + let a=F512_256::from(0); let f:f64=(-a).into(); assert_eq!(f,0f64); - let a=I256F256::from(237946589723468975i64)<<16; + let a=F512_256::from(237946589723468975i64)<<16; let f:f64=a.into(); assert_eq!(f,237946589723468975f64*2.0f64.powi(16)); } #[test] fn from_f32(){ - let a=I256F256::from(1)>>2; - let b:Result=0.25f32.try_into(); + let a=F512_256::from(1)>>2; + let b:Result=0.25f32.try_into(); assert_eq!(b,Ok(a)); - let a=I256F256::from(-1)>>2; - let b:Result=(-0.25f32).try_into(); + let a=F512_256::from(-1)>>2; + let b:Result=(-0.25f32).try_into(); assert_eq!(b,Ok(a)); - let a=I256F256::from(0); - let b:Result=0.try_into(); + let a=F512_256::from(0); + let b:Result=0.try_into(); assert_eq!(b,Ok(a)); - let a=I256F256::from(0b101011110101001010101010000000000000000000000000000i64)<<16; - let b:Result=(0b101011110101001010101010000000000000000000000000000u64 as f32*2.0f32.powi(16)).try_into(); + let a=F512_256::from(0b101011110101001010101010000000000000000000000000000i64)<<16; + let b:Result=(0b101011110101001010101010000000000000000000000000000u64 as f32*2.0f32.powi(16)).try_into(); assert_eq!(b,Ok(a)); //I32F32::MAX into f32 is truncated into this value - let a=I32F32::raw(0b111111111111111111111111000000000000000000000000000000000000000i64); - let b:Result=Into::::into(I32F32::MAX).try_into(); + let a=F64_32::raw(0b111111111111111111111111000000000000000000000000000000000000000i64); + let b:Result=Into::::into(F64_32::MAX).try_into(); assert_eq!(b,Ok(a)); //I32F32::MIN hits a special case since it's not representable as a positive signed integer //TODO: don't return an overflow because this is technically possible - let _a=I32F32::MIN; - let b:Result=Into::::into(I32F32::MIN).try_into(); + let _a=F64_32::MIN; + let b:Result=Into::::into(F64_32::MIN).try_into(); assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Overflow)); //16 is within the 24 bits of float precision - let b:Result=Into::::into(-I32F32::MIN.widen_128()).try_into(); + let b:Result=Into::::into(-F64_32::MIN.widen_128()).try_into(); assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Overflow)); - let b:Result=f32::MIN_POSITIVE.try_into(); + let b:Result=f32::MIN_POSITIVE.try_into(); assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Underflow)); //test many cases for i in 0..64{ @@ -77,132 +77,132 @@ fn from_f32(){ #[test] fn from_f64(){ - let a=I256F256::from(1)>>2; - let b:Result=0.25f64.try_into(); + let a=F512_256::from(1)>>2; + let b:Result=0.25f64.try_into(); assert_eq!(b,Ok(a)); - let a=I256F256::from(-1)>>2; - let b:Result=(-0.25f64).try_into(); + let a=F512_256::from(-1)>>2; + let b:Result=(-0.25f64).try_into(); assert_eq!(b,Ok(a)); - let a=I256F256::from(0); - let b:Result=0.try_into(); + let a=F512_256::from(0); + let b:Result=0.try_into(); assert_eq!(b,Ok(a)); - let a=I256F256::from(0b101011110101001010101010000000000000000000000000000i64)<<16; - let b:Result=(0b101011110101001010101010000000000000000000000000000u64 as f64*2.0f64.powi(16)).try_into(); + let a=F512_256::from(0b101011110101001010101010000000000000000000000000000i64)<<16; + let b:Result=(0b101011110101001010101010000000000000000000000000000u64 as f64*2.0f64.powi(16)).try_into(); assert_eq!(b,Ok(a)); } #[test] fn you_can_shr_numbers(){ - let a=I32F32::from(4); - assert_eq!(a>>1,I32F32::from(2)); + let a=F64_32::from(4); + assert_eq!(a>>1,F64_32::from(2)); } #[test] fn test_wide_mul(){ - let a=I32F32::ONE; + let a=F64_32::ONE; let aa=a.wide_mul_64_64(a); - assert_eq!(aa,crate::types::I64F64::ONE); + assert_eq!(aa,crate::types::F128_64::ONE); } #[test] fn test_wide_div(){ - let a=I32F32::ONE*4; - let b=I32F32::ONE*2; - let wide_a=a.wide_mul_64_64(I32F32::ONE); - let wide_b=b.wide_mul_64_64(I32F32::ONE); + let a=F64_32::ONE*4; + let b=F64_32::ONE*2; + let wide_a=a.wide_mul_64_64(F64_32::ONE); + let wide_b=b.wide_mul_64_64(F64_32::ONE); let ab=a.wide_div_64_64(b); - assert_eq!(ab,crate::types::I64F64::ONE*2); + assert_eq!(ab,crate::types::F128_64::ONE*2); let wab=wide_a.wide_div_128_64(b); - assert_eq!(wab,I96F96::ONE*2); + assert_eq!(wab,F192_96::ONE*2); let awb=a.wide_div_64_128(wide_b); - assert_eq!(awb,I96F96::ONE*2); + assert_eq!(awb,F192_96::ONE*2); } #[test] fn test_wide_mul_repeated() { - let a=I32F32::from(2); - let b=I32F32::from(3); + let a=F64_32::from(2); + let b=F64_32::from(3); let w1=a.wide_mul_64_64(b); let w2=w1.wide_mul_128_128(w1); let w3=w2.wide_mul_256_256(w2); - assert_eq!(w3,I256F256::from((3i128*2).pow(4))); + assert_eq!(w3,F512_256::from((3i128*2).pow(4))); } #[test] fn test_bint(){ - let a=I32F32::ONE; - assert_eq!(a*2,I32F32::from(2)); + let a=F64_32::ONE; + assert_eq!(a*2,F64_32::from(2)); } #[test] fn test_wrap(){ - assert_eq!(I32F32::ONE,I256F256::ONE.wrap_64()); - assert_eq!(I32F32::NEG_ONE,I256F256::NEG_ONE.wrap_64()); + assert_eq!(F64_32::ONE,F512_256::ONE.wrap_64()); + assert_eq!(F64_32::NEG_ONE,F512_256::NEG_ONE.wrap_64()); } #[test] fn test_narrow(){ - assert_eq!(Ok(I32F32::ONE),I256F256::ONE.narrow_64()); - assert_eq!(Ok(I32F32::NEG_ONE),I256F256::NEG_ONE.narrow_64()); + assert_eq!(Ok(F64_32::ONE),F512_256::ONE.narrow_64()); + assert_eq!(Ok(F64_32::NEG_ONE),F512_256::NEG_ONE.narrow_64()); } #[test] fn test_widen(){ - assert_eq!(I32F32::ONE.widen_512(),I256F256::ONE); - assert_eq!(I32F32::NEG_ONE.widen_512(),I256F256::NEG_ONE); + assert_eq!(F64_32::ONE.widen_512(),F512_256::ONE); + assert_eq!(F64_32::NEG_ONE.widen_512(),F512_256::NEG_ONE); } #[test] fn test_clamp(){ - assert_eq!(I32F32::ONE,I256F256::ONE.clamp_64()); - assert_eq!(I32F32::NEG_ONE,I256F256::NEG_ONE.clamp_64()); + assert_eq!(F64_32::ONE,F512_256::ONE.clamp_64()); + assert_eq!(F64_32::NEG_ONE,F512_256::NEG_ONE.clamp_64()); } #[test] fn test_sqrt(){ - let a=I32F32::ONE*4; - assert_eq!(a.sqrt(),I32F32::from(2)); + let a=F64_32::ONE*4; + assert_eq!(a.sqrt(),F64_32::from(2)); } #[test] fn test_sqrt_zero(){ - let a=I32F32::ZERO; - assert_eq!(a.sqrt(),I32F32::ZERO); + let a=F64_32::ZERO; + assert_eq!(a.sqrt(),F64_32::ZERO); } #[test] fn test_sqrt_low(){ - let a=I32F32::HALF; + let a=F64_32::HALF; let b=a.fixed_mul(a); assert_eq!(b.sqrt(),a); } -fn find_equiv_sqrt_via_f64(n:I32F32)->I32F32{ +fn find_equiv_sqrt_via_f64(n:F64_32)->F64_32{ //GIMME THEM BITS BOY let ibits=i64::from_le_bytes(n.to_bits().to_bytes()); let f=(ibits as f64)/((1u64<<32) as f64); let f_ans=f.sqrt(); let i=(f_ans*((1u64<<32) as f64)) as u64; - let r=I32F32::from_u64(i); + let r=F64_32::from_u64(i); //mimic the behaviour of the algorithm, //return the result if it truncates to the exact answer - if (r+I32F32::EPSILON).wide_mul_64_64(r+I32F32::EPSILON)==n.wide_mul_64_64(I32F32::ONE){ - return r+I32F32::EPSILON; + if (r+F64_32::EPSILON).wide_mul_64_64(r+F64_32::EPSILON)==n.wide_mul_64_64(F64_32::ONE){ + return r+F64_32::EPSILON; } - if (r-I32F32::EPSILON).wide_mul_64_64(r-I32F32::EPSILON)==n.wide_mul_64_64(I32F32::ONE){ - return r-I32F32::EPSILON; + if (r-F64_32::EPSILON).wide_mul_64_64(r-F64_32::EPSILON)==n.wide_mul_64_64(F64_32::ONE){ + return r-F64_32::EPSILON; } return r; } -fn test_exact(n:I32F32){ +fn test_exact(n:F64_32){ assert_eq!(n.sqrt(),find_equiv_sqrt_via_f64(n)); } #[test] fn test_sqrt_exact(){ //43 for i in 0..((i64::MAX as f32).ln() as u32){ - let n=I32F32::from_bits(bnum::BInt::<1>::from((i as f32).exp() as i64)); + let n=F64_32::from_bits(bnum::BInt::<1>::from((i as f32).exp() as i64)); test_exact(n); } } #[test] fn test_sqrt_max(){ - let a=I32F32::MAX; + let a=F64_32::MAX; test_exact(a); } #[test] @@ -210,9 +210,9 @@ fn test_sqrt_max(){ fn test_zeroes_normal(){ // (x-1)*(x+1) // x^2-1 - let zeroes=I32F32::zeroes2(I32F32::NEG_ONE,I32F32::ZERO,I32F32::ONE); + let zeroes=F64_32::zeroes2(F64_32::NEG_ONE,F64_32::ZERO,F64_32::ONE); assert_eq!(zeroes,arrayvec::ArrayVec::from_iter([I32F32::NEG_ONE,I32F32::ONE])); - let zeroes=I32F32::zeroes2(I32F32::NEG_ONE*3,I32F32::ONE*2,I32F32::ONE); + let zeroes=F64_32::zeroes2(F64_32::NEG_ONE*3,F64_32::ONE*2,F64_32::ONE); assert_eq!(zeroes,arrayvec::ArrayVec::from_iter([I32F32::NEG_ONE*3,I32F32::ONE])); } #[test] @@ -220,25 +220,25 @@ fn test_zeroes_normal(){ fn test_zeroes_deferred_division(){ // (x-1)*(x+1) // x^2-1 - let zeroes=I32F32::zeroes2(I32F32::NEG_ONE,I32F32::ZERO,I32F32::ONE); + let zeroes=F64_32::zeroes2(F64_32::NEG_ONE,F64_32::ZERO,F64_32::ONE); assert_eq!( zeroes, arrayvec::ArrayVec::from_iter([ - ratio_ops::ratio::Ratio::new(I32F32::ONE*2,I32F32::NEG_ONE*2), - ratio_ops::ratio::Ratio::new(I32F32::ONE*2,I32F32::ONE*2), + ratio_ops::ratio::Ratio::new(F64_32::ONE*2,F64_32::NEG_ONE*2), + ratio_ops::ratio::Ratio::new(F64_32::ONE*2,F64_32::ONE*2), ]) ); } #[test] fn test_debug(){ - assert_eq!(format!("{:?}",I32F32::EPSILON),"0.00000001"); - assert_eq!(format!("{:?}",I32F32::ONE),"1.00000000"); - assert_eq!(format!("{:?}",I32F32::TWO),"2.00000000"); - assert_eq!(format!("{:?}",I32F32::MAX),"7fffffff.ffffffff"); - assert_eq!(format!("{:?}",I32F32::try_from(core::f64::consts::PI).unwrap()),"3.243f6a88"); - assert_eq!(format!("{:?}",I32F32::NEG_EPSILON),"-0.00000001"); - assert_eq!(format!("{:?}",I32F32::NEG_ONE),"-1.00000000"); - assert_eq!(format!("{:?}",I32F32::NEG_TWO),"-2.00000000"); - assert_eq!(format!("{:?}",I32F32::MIN),"-80000000.00000000"); + assert_eq!(format!("{:?}",F64_32::EPSILON),"0.00000001"); + assert_eq!(format!("{:?}",F64_32::ONE),"1.00000000"); + assert_eq!(format!("{:?}",F64_32::TWO),"2.00000000"); + assert_eq!(format!("{:?}",F64_32::MAX),"7fffffff.ffffffff"); + assert_eq!(format!("{:?}",F64_32::try_from(core::f64::consts::PI).unwrap()),"3.243f6a88"); + assert_eq!(format!("{:?}",F64_32::NEG_EPSILON),"-0.00000001"); + assert_eq!(format!("{:?}",F64_32::NEG_ONE),"-1.00000000"); + assert_eq!(format!("{:?}",F64_32::NEG_TWO),"-2.00000000"); + assert_eq!(format!("{:?}",F64_32::MIN),"-80000000.00000000"); } diff --git a/lib/fixed_wide/src/types.rs b/lib/fixed_wide/src/types.rs index e8423cc8..0770f4ee 100644 --- a/lib/fixed_wide/src/types.rs +++ b/lib/fixed_wide/src/types.rs @@ -1,6 +1,6 @@ use crate::fixed::BNUM_DIGIT_WIDTH; -pub type I32F32=crate::fixed::Fixed<{64/BNUM_DIGIT_WIDTH},32>; -pub type I64F64=crate::fixed::Fixed<{128/BNUM_DIGIT_WIDTH},64>; -pub type I96F96=crate::fixed::Fixed<{192/BNUM_DIGIT_WIDTH},96>; -pub type I128F128=crate::fixed::Fixed<{256/BNUM_DIGIT_WIDTH},128>; -pub type I256F256=crate::fixed::Fixed<{512/BNUM_DIGIT_WIDTH},256>; +pub type F64_32=crate::fixed::Fixed<{64/BNUM_DIGIT_WIDTH},32>; +pub type F128_64=crate::fixed::Fixed<{128/BNUM_DIGIT_WIDTH},64>; +pub type F192_96=crate::fixed::Fixed<{192/BNUM_DIGIT_WIDTH},96>; +pub type F256_128=crate::fixed::Fixed<{256/BNUM_DIGIT_WIDTH},128>; +pub type F512_256=crate::fixed::Fixed<{512/BNUM_DIGIT_WIDTH},256>; diff --git a/lib/linear_ops/src/tests/fixed_wide.rs b/lib/linear_ops/src/tests/fixed_wide.rs index 7032fd07..aa8278cb 100644 --- a/lib/linear_ops/src/tests/fixed_wide.rs +++ b/lib/linear_ops/src/tests/fixed_wide.rs @@ -1,9 +1,9 @@ use crate::types::{Matrix3,Matrix3x2,Matrix3x4,Matrix4x2,Vector3}; -type Planar64=fixed_wide::types::I32F32; -type Planar64Wide1=fixed_wide::types::I64F64; +type Planar64=fixed_wide::types::F64_32; +type Planar64Wide1=fixed_wide::types::F128_64; //type Planar64Wide2=fixed_wide::types::I128F128; -type Planar64Wide3=fixed_wide::types::I256F256; +type Planar64Wide3=fixed_wide::types::F512_256; #[test] fn wide_vec3(){ -- 2.49.1 From 5d9e22fd041cb4831adb7961f1fcf53899c540b1 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 19:29:19 -0700 Subject: [PATCH 27/86] fix wrap_196 --- engine/physics/src/minimum_difference.rs | 2 +- engine/physics/src/minkowski.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/physics/src/minimum_difference.rs b/engine/physics/src/minimum_difference.rs index a082e1c0..f86e6a1c 100644 --- a/engine/physics/src/minimum_difference.rs +++ b/engine/physics/src/minimum_difference.rs @@ -578,7 +578,7 @@ impl ThickPlane{ let normal=(p1-p0).cross(p2-p0); // Allow ~ 2*sqrt(3) units of thickness on the plane // This is to account for the variance of two voxels across the longest diagonal - let epsilon=(normal.length()*(Planar64::EPSILON*3)).wrap_196(); + let epsilon=(normal.length()*(Planar64::EPSILON*3)).wrap_192(); Self{point,normal,epsilon} } } diff --git a/engine/physics/src/minkowski.rs b/engine/physics/src/minkowski.rs index 2bb63f96..db009920 100644 --- a/engine/physics/src/minkowski.rs +++ b/engine/physics/src/minkowski.rs @@ -242,7 +242,7 @@ impl MeshTopology for MinkowskiMesh<'_>{ for face_n in &v1f_n{ //add reflected mesh1 faces //wrap for speed - face_normals.push(*face_n-(n*face_n.dot(n)*2/nn).divide().wrap_196()); + face_normals.push(*face_n-(n*face_n.dot(n)*2/nn).divide().wrap_192()); } if is_empty_volume(&face_normals){ f(MinkowskiDirectedEdge::EdgeVert(directed_edge_id,v1)); @@ -257,7 +257,7 @@ impl MeshTopology for MinkowskiMesh<'_>{ // make a set of faces from mesh1's perspective for face_n in &v0f_n{ //wrap for speed - face_normals.push(*face_n-(n*face_n.dot(n)*2/nn).divide().wrap_196()); + face_normals.push(*face_n-(n*face_n.dot(n)*2/nn).divide().wrap_192()); } if is_empty_volume(&face_normals){ f(MinkowskiDirectedEdge::VertEdge(v0,directed_edge_id)); -- 2.49.1 From 2b213cb8bde41552843fe5658f625c51c314b0e3 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 19:44:25 -0700 Subject: [PATCH 28/86] fixes --- engine/physics/src/minkowski.rs | 6 +++--- lib/fixed_wide/src/fixed.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/physics/src/minkowski.rs b/engine/physics/src/minkowski.rs index db009920..37b7f23e 100644 --- a/engine/physics/src/minkowski.rs +++ b/engine/physics/src/minkowski.rs @@ -1,6 +1,6 @@ use core::ops::{Bound,RangeBounds}; -use strafesnet_common::integer::fixed_types::{F192_96,F256_128}; +use strafesnet_common::integer::fixed_types::{F192_96,F256_128,F512_256}; use strafesnet_common::integer::vec3::Vector3; use strafesnet_common::integer::{Planar64Vec3,Ratio,Fixed}; use crate::model::into_giga_time; @@ -281,7 +281,7 @@ impl MeshTopology for MinkowskiMesh<'_>{ let &[e1f0,e1f1]=self.mesh1.edge_faces(e1).as_ref(); AsRefHelper([(e1f1,false),(e1f0,true)].map(|(edge_face_id1,face_parity)|{ let mut best_edge=None; - let mut best_d:Ratio,Fixed<8,256>>=Ratio::new(Fixed::ZERO,Fixed::ONE); + let mut best_d:Ratio=Ratio::new(Fixed::ZERO,Fixed::ONE); let edge_face1_n=self.mesh1.face_nd(edge_face_id1).0; let edge_face1_nn=edge_face1_n.dot(edge_face1_n); for &directed_edge_id0 in &v0e{ @@ -315,7 +315,7 @@ impl MeshTopology for MinkowskiMesh<'_>{ let &[e0f0,e0f1]=self.mesh0.edge_faces(e0).as_ref(); AsRefHelper([(e0f0,true),(e0f1,false)].map(|(edge_face_id0,face_parity)|{ let mut best_edge=None; - let mut best_d:Ratio,Fixed<8,256>>=Ratio::new(Fixed::ZERO,Fixed::ONE); + let mut best_d:Ratio=Ratio::new(Fixed::ZERO,Fixed::ONE); let edge_face0_n=self.mesh0.face_nd(edge_face_id0).0; let edge_face0_nn=edge_face0_n.dot(edge_face0_n); for &directed_edge_id1 in &v1e{ diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 3068dd12..9dee86ac 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -104,7 +104,7 @@ impl Fixed{ } } } -impl Fixed<8,F>{ +impl Fixed<{64/BNUM_DIGIT_WIDTH},F>{ /// My old code called this function everywhere so let's provide it #[inline] pub const fn raw(value:i64)->Self{ -- 2.49.1 From 896d8b6f4c4801910c3e646231fc4d91bf3d1225 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 20:40:35 -0700 Subject: [PATCH 29/86] ilog2 --- lib/fixed_wide/src/fixed.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 9dee86ac..d86d0230 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -156,7 +156,7 @@ macro_rules! impl_into_float { impl Into<$output> for Fixed{ #[inline] fn into(self)->$output{ - const DIGIT_SHIFT:u32=3;//Log2[BNUM_DIGIT_WIDTH] + const DIGIT_SHIFT:u32=BNUM_DIGIT_WIDTH.ilog2(); // SBBB BBBB // 1001 1110 0000 0000 let sign=if self.bits.is_negative(){(1 as $unsigned)<<(<$unsigned>::BITS-1)}else{0}; @@ -252,7 +252,7 @@ macro_rules! impl_from_float { type Error=FixedFromFloatError; #[inline] fn try_from(value:$input)->Result{ - const DIGIT_SHIFT:u32=3;//Log[BNUM_DIGIT_WIDTH] + const DIGIT_SHIFT:u32=BNUM_DIGIT_WIDTH.ilog2(); match value.classify(){ std::num::FpCategory::Nan=>Err(FixedFromFloatError::Nan), std::num::FpCategory::Infinite=>Err(FixedFromFloatError::Infinite), -- 2.49.1 From 645b29ed5516513a7f41f745ab73eae03acefec0 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 19 Mar 2026 21:35:15 -0700 Subject: [PATCH 30/86] more type usage --- engine/physics/src/push_solve.rs | 20 ++++++++++---------- lib/bsp_loader/src/brush.rs | 13 +++++++------ lib/common/src/aabb.rs | 2 +- lib/common/src/integer.rs | 6 +++--- lib/fixed_wide/src/tests.rs | 12 +++++------- lib/fixed_wide/src/types.rs | 1 + 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/engine/physics/src/push_solve.rs b/engine/physics/src/push_solve.rs index 8b902dec..7d54ca3e 100644 --- a/engine/physics/src/push_solve.rs +++ b/engine/physics/src/push_solve.rs @@ -1,4 +1,4 @@ -use strafesnet_common::integer::fixed_types::F64_32; +use strafesnet_common::integer::fixed_types::{F64_32,F128_64,F192_96,F256_128,F320_160}; use strafesnet_common::integer::vec3::{self,Vector3}; use strafesnet_common::integer::{Fixed,Planar64Vec3,Ratio}; use strafesnet_common::ray::Ray; @@ -30,17 +30,17 @@ impl Contact{ normal:self.normal, } } - fn relative_dot(&self,direction:Planar64Vec3)->Fixed<2,64>{ + fn relative_dot(&self,direction:Planar64Vec3)->F128_64{ (direction-self.velocity).dot(self.normal) } /// Calculate the time of intersection. (previously get_touch_time) - fn solve(&self,ray:&Ray)->Ratio,Fixed<2,64>>{ + fn solve(&self,ray:&Ray)->Ratio{ (self.position-ray.origin).dot(self.normal)/(ray.direction-self.velocity).dot(self.normal) } } //note that this is horrible with fixed point arithmetic -fn solve1(c0:&Contact)->Option>,Fixed<2,64>>>{ +fn solve1(c0:&Contact)->Option,F128_64>>{ let det=c0.normal.dot(c0.velocity); if det.abs()==Fixed::ZERO{ return None; @@ -48,7 +48,7 @@ fn solve1(c0:&Contact)->Option>,Fixed<2,64>>>{ let d0=c0.normal.dot(c0.position); Some(c0.normal*d0/det) } -fn solve2(c0:&Contact,c1:&Contact)->Option>,Fixed<4,128>>>{ +fn solve2(c0:&Contact,c1:&Contact)->Option,F256_128>>{ let u0_u1=c0.velocity.cross(c1.velocity); let n0_n1=c0.normal.cross(c1.normal); let det=u0_u1.dot(n0_n1); @@ -59,7 +59,7 @@ fn solve2(c0:&Contact,c1:&Contact)->Option>,Fixed<4,1 let d1=c1.normal.dot(c1.position); Some((c1.normal.cross(u0_u1)*d0+u0_u1.cross(c0.normal)*d1)/det) } -fn solve3(c0:&Contact,c1:&Contact,c2:&Contact)->Option>,Fixed<3,96>>>{ +fn solve3(c0:&Contact,c1:&Contact,c2:&Contact)->Option,F192_96>>{ let n0_n1=c0.normal.cross(c1.normal); let det=c2.normal.dot(n0_n1); if det.abs()==Fixed::ZERO{ @@ -71,7 +71,7 @@ fn solve3(c0:&Contact,c1:&Contact,c2:&Contact)->OptionOption<[Ratio,Fixed<2,64>>;1]>{ +fn decompose1(point:Planar64Vec3,u0:Planar64Vec3)->Option<[Ratio;1]>{ let det=u0.dot(u0); if det==Fixed::ZERO{ return None; @@ -79,7 +79,7 @@ fn decompose1(point:Planar64Vec3,u0:Planar64Vec3)->Option<[Ratio,Fix let s0=u0.dot(point)/det; Some([s0]) } -fn decompose2(point:Planar64Vec3,u0:Planar64Vec3,u1:Planar64Vec3)->Option<[Ratio,Fixed<4,128>>;2]>{ +fn decompose2(point:Planar64Vec3,u0:Planar64Vec3,u1:Planar64Vec3)->Option<[Ratio;2]>{ let u0_u1=u0.cross(u1); let det=u0_u1.dot(u0_u1); if det==Fixed::ZERO{ @@ -89,7 +89,7 @@ fn decompose2(point:Planar64Vec3,u0:Planar64Vec3,u1:Planar64Vec3)->Option<[Ratio let s1=u0_u1.dot(u0.cross(point))/det; Some([s0,s1]) } -fn decompose3(point:Planar64Vec3,u0:Planar64Vec3,u1:Planar64Vec3,u2:Planar64Vec3)->Option<[Ratio,Fixed<3,96>>;3]>{ +fn decompose3(point:Planar64Vec3,u0:Planar64Vec3,u1:Planar64Vec3,u2:Planar64Vec3)->Option<[Ratio;3]>{ let det=u0.cross(u1).dot(u2); if det==Fixed::ZERO{ return None; @@ -273,7 +273,7 @@ fn get_best_push_ray_and_conts<'a>( } } -fn get_first_touch<'a>(contacts:&'a [Contact],ray:&Ray,conts:&Conts)->Option<(Ratio,Fixed<2,64>>,&'a Contact)>{ +fn get_first_touch<'a>(contacts:&'a [Contact],ray:&Ray,conts:&Conts)->Option<(Ratio,&'a Contact)>{ contacts.iter() .filter(|&contact| !conts.iter().any(|&c|std::ptr::eq(c,contact)) diff --git a/lib/bsp_loader/src/brush.rs b/lib/bsp_loader/src/brush.rs index 4f5283eb..9a5f9ec5 100644 --- a/lib/bsp_loader/src/brush.rs +++ b/lib/bsp_loader/src/brush.rs @@ -1,21 +1,22 @@ -use strafesnet_common::integer::Planar64; use strafesnet_common::{model,integer}; -use strafesnet_common::integer::{vec3::Vector3,Fixed,Ratio}; +use strafesnet_common::integer::fixed_types::F192_96; +use strafesnet_common::integer::vec3::Vector3; +use strafesnet_common::integer::{Fixed,Planar64,Planar64Vec3,Ratio}; use crate::{valve_transform_normal,valve_transform_dist}; #[derive(Hash,Eq,PartialEq)] struct Face{ - normal:integer::Planar64Vec3, + normal:Planar64Vec3, dot:Planar64, } #[derive(Debug)] struct Faces{ - faces:Vec>, + faces:Vec>, } -fn solve3(c0:&Face,c1:&Face,c2:&Face)->Option>,Fixed<3,96>>>{ +fn solve3(c0:&Face,c1:&Face,c2:&Face)->Option,F192_96>>{ let n0_n1=c0.normal.cross(c1.normal); let det=c2.normal.dot(n0_n1); if det.abs().is_zero(){ @@ -204,7 +205,7 @@ impl std::fmt::Display for BrushToMeshError{ } impl core::error::Error for BrushToMeshError{} -pub fn faces_to_mesh(faces:Vec>)->model::Mesh{ +pub fn faces_to_mesh(faces:Vec>)->model::Mesh{ // generate the mesh let mut mb=model::MeshBuilder::new(); let color=mb.acquire_color_id(glam::Vec4::ONE); diff --git a/lib/common/src/aabb.rs b/lib/common/src/aabb.rs index af3e2596..28348d78 100644 --- a/lib/common/src/aabb.rs +++ b/lib/common/src/aabb.rs @@ -62,7 +62,7 @@ impl Aabb{ self.min.map_zip(self.max,|(min,max)|min.midpoint(max)) } #[inline] - pub fn area_weight(&self)->fixed_wide::fixed::Fixed<2,64>{ + pub fn area_weight(&self)->fixed_wide::fixed::F128_64{ let d=self.max-self.min; d.x*d.y+d.y*d.z+d.z*d.x } diff --git a/lib/common/src/integer.rs b/lib/common/src/integer.rs index 229da3c3..9579bbb0 100644 --- a/lib/common/src/integer.rs +++ b/lib/common/src/integer.rs @@ -140,7 +140,7 @@ impl_time_additive_assign_operator!(core::ops::AddAssign,add_assign); impl_time_additive_assign_operator!(core::ops::SubAssign,sub_assign); impl_time_additive_assign_operator!(core::ops::RemAssign,rem_assign); impl std::ops::Mul for Time{ - type Output=Ratio,Fixed<2,64>>; + type Output=Ratio; #[inline] fn mul(self,rhs:Self)->Self::Output{ Ratio::new(Fixed::raw(self.0)*Fixed::raw(rhs.0),Fixed::from_u64(1_000_000_000u64.pow(2))) @@ -162,7 +162,7 @@ impl_time_i64_rhs_operator!(Mul,mul); impl_time_i64_rhs_operator!(Shr,shr); impl_time_i64_rhs_operator!(Shl,shl); impl core::ops::Mul> for Planar64{ - type Output=Ratio,Planar64>; + type Output=Ratio; #[inline] fn mul(self,rhs:Time)->Self::Output{ Ratio::new(self*Fixed::raw(rhs.0),Planar64::raw(1_000_000_000)) @@ -725,7 +725,7 @@ impl Planar64Affine3{ } } #[inline] - pub fn transform_point3(&self,point:Planar64Vec3)->vec3::Vector3>{ + pub fn transform_point3(&self,point:Planar64Vec3)->vec3::Vector3{ self.translation.widen_128()+self.matrix3*point } } diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 8575d672..cfb9a729 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -1,6 +1,4 @@ -use crate::types::F64_32; -use crate::types::F192_96; -use crate::types::F512_256; +use crate::types::{F64_32,F128_64,F192_96,F512_256}; #[test] fn you_can_add_numbers(){ @@ -68,9 +66,9 @@ fn from_f32(){ assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Underflow)); //test many cases for i in 0..64{ - let a=crate::fixed::Fixed::<2,64>::from_u64(0b111111111111111111111111000000000000000000000000000000000000000u64)<,_>=f.try_into(); + let b:Result=f.try_into(); assert_eq!(b,Ok(a)); } } @@ -101,7 +99,7 @@ fn you_can_shr_numbers(){ fn test_wide_mul(){ let a=F64_32::ONE; let aa=a.wide_mul_64_64(a); - assert_eq!(aa,crate::types::F128_64::ONE); + assert_eq!(aa,F128_64::ONE); } #[test] @@ -111,7 +109,7 @@ fn test_wide_div(){ let wide_a=a.wide_mul_64_64(F64_32::ONE); let wide_b=b.wide_mul_64_64(F64_32::ONE); let ab=a.wide_div_64_64(b); - assert_eq!(ab,crate::types::F128_64::ONE*2); + assert_eq!(ab,F128_64::ONE*2); let wab=wide_a.wide_div_128_64(b); assert_eq!(wab,F192_96::ONE*2); let awb=a.wide_div_64_128(wide_b); diff --git a/lib/fixed_wide/src/types.rs b/lib/fixed_wide/src/types.rs index 0770f4ee..64c2b279 100644 --- a/lib/fixed_wide/src/types.rs +++ b/lib/fixed_wide/src/types.rs @@ -3,4 +3,5 @@ pub type F64_32=crate::fixed::Fixed<{64/BNUM_DIGIT_WIDTH},32>; pub type F128_64=crate::fixed::Fixed<{128/BNUM_DIGIT_WIDTH},64>; pub type F192_96=crate::fixed::Fixed<{192/BNUM_DIGIT_WIDTH},96>; pub type F256_128=crate::fixed::Fixed<{256/BNUM_DIGIT_WIDTH},128>; +pub type F320_160=crate::fixed::Fixed<{320/BNUM_DIGIT_WIDTH},160>; pub type F512_256=crate::fixed::Fixed<{512/BNUM_DIGIT_WIDTH},256>; -- 2.49.1 From 9e64e311c6d5deaef81d0927cce33378c11bd6a9 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 06:54:28 -0700 Subject: [PATCH 31/86] mistake --- lib/fixed_wide/src/zeroes.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/fixed_wide/src/zeroes.rs b/lib/fixed_wide/src/zeroes.rs index 79359a40..ac52e0de 100644 --- a/lib/fixed_wide/src/zeroes.rs +++ b/lib/fixed_wide/src/zeroes.rs @@ -23,14 +23,14 @@ macro_rules! impl_zeroes{ } //sort roots ascending and avoid taking the difference of large numbers let zeroes=match (a2pos,Self::ZERO[(-a1-planar_radicand)/(a2>>1),(a0>>1)/(-a1-planar_radicand)], - (true, false)=>[(a0>>1)/(-a1+planar_radicand),(-a1+planar_radicand)/(a2>>1)], - (false,true )=>[(a0>>1)/(-a1-planar_radicand),(-a1-planar_radicand)/(a2>>1)], - (false,false)=>[(-a1+planar_radicand)/(a2>>1),(a0>>1)/(-a1+planar_radicand)], + (true, true )=>[(-a1-planar_radicand)/(a2<<1),(a0<<1)/(-a1-planar_radicand)], + (true, false)=>[(a0<<1)/(-a1+planar_radicand),(-a1+planar_radicand)/(a2<<1)], + (false,true )=>[(a0<<1)/(-a1-planar_radicand),(-a1-planar_radicand)/(a2<<1)], + (false,false)=>[(-a1+planar_radicand)/(a2<<1),(a0<<1)/(-a1+planar_radicand)], }; ArrayVec::from_iter(zeroes) }, - Ordering::Equal=>ArrayVec::from_iter([(a1)/(-a2>>1)]), + Ordering::Equal=>ArrayVec::from_iter([(a1)/(-a2<<1)]), Ordering::Less=>ArrayVec::new_const(), } } -- 2.49.1 From 3d6dc26fdeb6ba6077c2dc60515de6915fb269aa Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:25:39 -0700 Subject: [PATCH 32/86] impl_from_float --- lib/fixed_wide/src/fixed.rs | 73 ++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index d86d0230..f3c84d7e 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -199,32 +199,28 @@ impl_into_float!(f32,u32,8,24); impl_into_float!(f64,u64,11,53); #[inline] -fn integer_decode_f32(f: f32) -> (u64, i16, bool) { +fn integer_decode_f32(f: f32) -> (u32, u8, bool) { let bits: u32 = f.to_bits(); let sign: bool = bits & (1<<31) != 0; - let mut exponent: i16 = ((bits >> 23) & 0xff) as i16; + let exponent = (bits >> 23) & 0xff; let mantissa = if exponent == 0 { (bits & 0x7fffff) << 1 } else { (bits & 0x7fffff) | 0x800000 }; - // Exponent bias + mantissa shift - exponent -= 127 + 23; - (mantissa as u64, exponent, sign) + (mantissa, exponent as u8, sign) } #[inline] -fn integer_decode_f64(f: f64) -> (u64, i16, bool) { +fn integer_decode_f64(f: f64) -> (u64, u16, bool) { let bits: u64 = f.to_bits(); let sign: bool = bits & (1u64<<63) != 0; - let mut exponent: i16 = ((bits >> 52) & 0x7ff) as i16; + let exponent = (bits >> 52) & 0x7ff; let mantissa = if exponent == 0 { (bits & 0xfffffffffffff) << 1 } else { (bits & 0xfffffffffffff) | 0x10000000000000 }; - // Exponent bias + mantissa shift - exponent -= 1023 + 52; - (mantissa, exponent, sign) + (mantissa, exponent as u16, sign) } #[derive(Debug,Eq,PartialEq)] pub enum FixedFromFloatError{ @@ -246,8 +242,8 @@ impl core::fmt::Display for FixedFromFloatError{ write!(f,"{self:?}") } } -macro_rules! impl_from_float { - ( $decode:ident, $input: ty, $mantissa_bits:expr ) => { +macro_rules! impl_from_float{ + ($decode:ident,$input:ty,$mantissa_bits:expr,$bias:expr)=>{ impl TryFrom<$input> for Fixed{ type Error=FixedFromFloatError; #[inline] @@ -262,24 +258,41 @@ macro_rules! impl_from_float { =>{ let (m,e,s)=$decode(value); let mut digits=[0u8;N]; - let most_significant_bit=e as i32+$mantissa_bits as i32+F as i32; - if most_significant_bit<0{ + let lsb_biased=e as usize+F; + if lsb_biased+$mantissa_bits<$bias{ return Err(FixedFromFloatError::Underflow); + }; + if N*BNUM_DIGIT_WIDTH+$bias<=lsb_biased{ + return Err(FixedFromFloatError::Overflow); } - let digit_index=most_significant_bit>>DIGIT_SHIFT; - let digit=digits.get_mut(digit_index as usize).ok_or(FixedFromFloatError::Overflow)?; - let take_bits=most_significant_bit-(digit_index<>DIGIT_SHIFT; + let mut i_d=0; + while i_m>DIGIT_SHIFT; + while i_m core::fmt::Debug for Fixed{ #[inline] -- 2.49.1 From b541845a753907870e2a8303d483d5066bbf40b8 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:34:25 -0700 Subject: [PATCH 33/86] wip impl_into_float --- lib/fixed_wide/src/fixed.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index f3c84d7e..be127cf9 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -151,8 +151,8 @@ impl std::iter::Sum for Fixed{ } } -macro_rules! impl_into_float { - ( $output: ty, $unsigned:ty, $exponent_bits:expr, $mantissa_bits:expr ) => { +macro_rules! impl_into_float{ + ($output:ty,$unsigned:ty,$mantissa_bits:expr,$bias:expr) => { impl Into<$output> for Fixed{ #[inline] fn into(self)->$output{ @@ -166,8 +166,7 @@ macro_rules! impl_into_float { 0 }else{ let msb=most_significant_bit as $unsigned; - let _127=((1 as $unsigned)<<($exponent_bits-1))-1; - let msb_offset=msb+_127-1-F as $unsigned; + let msb_offset=msb+$bias-1-F as $unsigned; msb_offset<<($mantissa_bits-1) }; let digits=unsigned.to_bytes(); @@ -195,8 +194,8 @@ macro_rules! impl_into_float { } } } -impl_into_float!(f32,u32,8,24); -impl_into_float!(f64,u64,11,53); +impl_into_float!(f32,u32,24,127); +impl_into_float!(f64,u64,53,1023); #[inline] fn integer_decode_f32(f: f32) -> (u32, u8, bool) { -- 2.49.1 From 73cffeae89d0fc9df44f850923e84e2ac5c006f7 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:41:21 -0700 Subject: [PATCH 34/86] unused --- lib/fixed_wide/src/fixed.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index be127cf9..5a40fd64 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -1,8 +1,6 @@ use bnum::{Int,cast::As,n}; pub(crate)const BNUM_DIGIT_WIDTH:usize=8; -/// how many bnum 14 digits are there per bnum 13 digit -const BNUM_13_COMPAT:usize=64/8; #[derive(Clone,Copy,Default,Hash,PartialEq,Eq,PartialOrd,Ord)] /// A Fixed point number for which multiply operations widen the bits in the output. (when the wide-mul feature is enabled) -- 2.49.1 From a416a40d5e9d5c3dccf14df98b6232a780be2f72 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:41:31 -0700 Subject: [PATCH 35/86] fix from int --- lib/fixed_wide/src/fixed.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 5a40fd64..33edfd34 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -466,12 +466,12 @@ macro_rules! impl_multiplicative_operator { ( $trait: ident, $method: ident, $inner_method: ident, $output: ty ) => { impl core::ops::$trait for Fixed where - Int:::From+core::ops::$trait, + Int:::bnum::cast::CastFrom+core::ops::$trait, { type Output = $output; #[inline] fn $method(self,other:U)->Self::Output{ - Self::from_bits(self.bits.$inner_method(Int::::from(other))) + Self::from_bits(self.bits.$inner_method(other.as_())) } } }; @@ -480,11 +480,11 @@ macro_rules! impl_multiplicative_assign_operator { ( $trait: ident, $method: ident, $not_assign_method: ident ) => { impl core::ops::$trait for Fixed where - Int:::From+core::ops::$trait, + Int:::bnum::cast::CastFrom+core::ops::$trait, { #[inline] fn $method(&mut self,other:U){ - self.bits=self.bits.$not_assign_method(Int::::from(other)); + self.bits=self.bits.$not_assign_method(other.as_()); } } }; -- 2.49.1 From 9956a9bd1dea9b12b529e994ac5c83f2be6098c9 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:41:35 -0700 Subject: [PATCH 36/86] fix tests --- lib/fixed_wide/src/tests.rs | 2 +- lib/linear_ops/src/tests/fixed_wide.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index cfb9a729..06c70dd5 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -194,7 +194,7 @@ fn test_exact(n:F64_32){ fn test_sqrt_exact(){ //43 for i in 0..((i64::MAX as f32).ln() as u32){ - let n=F64_32::from_bits(bnum::BInt::<1>::from((i as f32).exp() as i64)); + let n=F64_32::from_u64((i as f32).exp() as u64); test_exact(n); } } diff --git a/lib/linear_ops/src/tests/fixed_wide.rs b/lib/linear_ops/src/tests/fixed_wide.rs index aa8278cb..f0c8dba9 100644 --- a/lib/linear_ops/src/tests/fixed_wide.rs +++ b/lib/linear_ops/src/tests/fixed_wide.rs @@ -72,7 +72,7 @@ fn wide_matrix_det(){ ]); // In[2]:= Det[{{1, 2, 3}, {4, 5, 7}, {6, 8, 9}}] // Out[2]= 7 - assert_eq!(m.det(),fixed_wide::fixed::Fixed::<3,96>::from(7)); + assert_eq!(m.det(),fixed_wide::types::F192_96::from(7)); } #[test] -- 2.49.1 From afd7db8c9021e7b837a697eb3494b3ed0af23f5a Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:41:39 -0700 Subject: [PATCH 37/86] shut up pls --- lib/fixed_wide/src/fixed.rs | 69 +++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 33edfd34..c7144bc7 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -154,40 +154,41 @@ macro_rules! impl_into_float{ impl Into<$output> for Fixed{ #[inline] fn into(self)->$output{ - const DIGIT_SHIFT:u32=BNUM_DIGIT_WIDTH.ilog2(); - // SBBB BBBB - // 1001 1110 0000 0000 - let sign=if self.bits.is_negative(){(1 as $unsigned)<<(<$unsigned>::BITS-1)}else{0}; - let unsigned=self.bits.unsigned_abs(); - let most_significant_bit=unsigned.bit_width(); - let exp=if unsigned.is_zero(){ - 0 - }else{ - let msb=most_significant_bit as $unsigned; - let msb_offset=msb+$bias-1-F as $unsigned; - msb_offset<<($mantissa_bits-1) - }; - let digits=unsigned.to_bytes(); - let digit_index=most_significant_bit.saturating_sub(1)>>DIGIT_SHIFT; - let digit=digits[digit_index as usize]; - //How many bits does the mantissa take from this digit - let take_bits=most_significant_bit-(digit_index<::from_bits(bits) + panic!() + // const DIGIT_SHIFT:u32=BNUM_DIGIT_WIDTH.ilog2(); + // // SBBB BBBB + // // 1001 1110 0000 0000 + // let sign=if self.bits.is_negative(){(1 as $unsigned)<<(<$unsigned>::BITS-1)}else{0}; + // let unsigned=self.bits.unsigned_abs(); + // let most_significant_bit=unsigned.bit_width(); + // let exp=if unsigned.is_zero(){ + // 0 + // }else{ + // let msb=most_significant_bit as $unsigned; + // let msb_offset=msb+$bias-1-F as $unsigned; + // msb_offset<<($mantissa_bits-1) + // }; + // let digits=unsigned.to_bytes(); + // let digit_index=most_significant_bit.saturating_sub(1)>>DIGIT_SHIFT; + // let digit=digits[digit_index as usize]; + // //How many bits does the mantissa take from this digit + // let take_bits=most_significant_bit-(digit_index<::from_bits(bits) } } } -- 2.49.1 From 7b307ae4c0a2e4fa1563145907671b43dcc09626 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:42:54 -0700 Subject: [PATCH 38/86] fix macro --- lib/fixed_wide/src/fixed.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index c7144bc7..32ab3f36 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -424,7 +424,7 @@ macro_rules! impl_multiply_operator_not_const_generic { } } #[cfg(not(feature="wide-mul"))] - impl_multiplicative_operator_not_const_generic!(($struct, $trait, $method, $output ), $width); + impl_multiplicative_operator_not_const_generic!(($trait,$method,$output),$width); #[cfg(feature="deferred-division")] impl ratio_ops::ratio::Divide for Fixed<{$width/BNUM_DIGIT_WIDTH},{$width>>1}>{ type Output=Self; @@ -449,7 +449,7 @@ macro_rules! impl_divide_operator_not_const_generic { } } #[cfg(all(not(feature="wide-mul"),not(feature="deferred-division")))] - impl_multiplicative_operator_not_const_generic!(($struct, $trait, $method, $output ), $width); + impl_multiplicative_operator_not_const_generic!(($trait,$method,$output),$width); #[cfg(all(not(feature="wide-mul"),feature="deferred-division"))] impl ratio_ops::ratio::Divide for Fixed<{$width/BNUM_DIGIT_WIDTH},F>{ type Output = $output; -- 2.49.1 From a6149b2daaf3a785284a99d743136edb37564530 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:53:25 -0700 Subject: [PATCH 39/86] suff --- lib/linear_ops/src/macros/fixed_wide.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/linear_ops/src/macros/fixed_wide.rs b/lib/linear_ops/src/macros/fixed_wide.rs index 1434ea66..21dc4e58 100644 --- a/lib/linear_ops/src/macros/fixed_wide.rs +++ b/lib/linear_ops/src/macros/fixed_wide.rs @@ -5,17 +5,17 @@ macro_rules! impl_fixed_wide_vector_not_const_generic { (), $n:expr ) => { - impl Vector>{ + impl Vector>3},{$n>>1}>>{ #[inline] - pub fn length(self)-> as core::ops::Mul>::Output{ + pub fn length(self)->>3},{$n>>1}> as core::ops::Mul>::Output{ self.length_squared().sqrt_unchecked() } #[inline] - pub fn with_length(self,length:U)-> as core::ops::Div< as core::ops::Mul>::Output>>::Output + pub fn with_length(self,length:U)-> as core::ops::Div<>3},{$n>>1}> as core::ops::Mul>::Output>>::Output where - fixed_wide::fixed::Fixed<$n,{$n*32}>:core::ops::Mul, + fixed_wide::fixed::Fixed<{$n>>3},{$n>>1}>:core::ops::Mul, U:Copy, - V:core::ops::Div< as core::ops::Mul>::Output>, + V:core::ops::Div<>3},{$n>>1}> as core::ops::Mul>::Output>, { self*length/self.length() } @@ -98,17 +98,17 @@ macro_rules! impl_narrow_not_const_generic{ ($lhs:expr,$rhs:expr) )=>{ paste::item!{ - impl Vector>{ + impl Vector>3},{$lhs>>1}>>{ #[inline] - pub fn [](self)->Vector>{ + pub fn [](self)->Vector>3},{$rhs>>1}>>{ self.map(|t|t.[]()) } #[inline] - pub fn [](self)->Vector,fixed_wide::fixed::NarrowError>>{ + pub fn [](self)->Vector>3},{$rhs>>1}>,fixed_wide::fixed::NarrowError>>{ self.map(|t|t.[]()) } #[inline] - pub fn [](self)->Vector>{ + pub fn [](self)->Vector>3},{$rhs>>1}>>{ self.map(|t|t.[]()) } } @@ -123,9 +123,9 @@ macro_rules! impl_widen_not_const_generic{ ($lhs:expr,$rhs:expr) )=>{ paste::item!{ - impl Vector>{ + impl Vector>3},{$lhs>>1}>>{ #[inline] - pub fn [](self)->Vector>{ + pub fn [](self)->Vector>3},{$rhs>>1}>>{ self.map(|t|t.[]()) } } -- 2.49.1 From b8f775acebdbaafc705d786556f3cb4d11a6279f Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:57:53 -0700 Subject: [PATCH 40/86] 4-17 --- lib/linear_ops/src/macros/fixed_wide.rs | 60 ++++++++++++------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/linear_ops/src/macros/fixed_wide.rs b/lib/linear_ops/src/macros/fixed_wide.rs index 21dc4e58..a914532d 100644 --- a/lib/linear_ops/src/macros/fixed_wide.rs +++ b/lib/linear_ops/src/macros/fixed_wide.rs @@ -27,7 +27,7 @@ macro_rules! impl_fixed_wide_vector_not_const_generic { #[macro_export(local_inner_macros)] macro_rules! macro_4 { ( $macro: ident, $any:tt ) => { - $crate::macro_repeated!($macro,$any,1,2,3,4); + $crate::macro_repeated!($macro,$any,1,2,3,256); } } @@ -39,40 +39,40 @@ macro_rules! impl_fixed_wide_vector { // I LOVE NOT BEING ABLE TO USE CONST GENERICS $crate::macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1),(14,1),(15,1),(16,1),(17,1), - (3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(9,2),(10,2),(11,2),(12,2),(13,2),(14,2),(15,2),(16,2), - (4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(10,3),(11,3),(12,3),(13,3),(14,3),(15,3),(16,3), - (5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(11,4),(12,4),(13,4),(14,4),(15,4),(16,4), - (6,5),(7,5),(8,5),(9,5),(10,5),(11,5),(12,5),(13,5),(14,5),(15,5),(16,5), - (7,6),(8,6),(9,6),(10,6),(11,6),(12,6),(13,6),(14,6),(15,6),(16,6), - (8,7),(9,7),(10,7),(11,7),(12,7),(13,7),(14,7),(15,7),(16,7), - (9,8),(10,8),(11,8),(12,8),(13,8),(14,8),(15,8),(16,8), - (10,9),(11,9),(12,9),(13,9),(14,9),(15,9),(16,9), - (11,10),(12,10),(13,10),(14,10),(15,10),(16,10), - (12,11),(13,11),(14,11),(15,11),(16,11), - (13,12),(14,12),(15,12),(16,12), - (14,13),(15,13),(16,13), - (15,14),(16,14), - (16,15) + (2,1),(3,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (3,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (256,3),(320,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), + (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256),(832,256),(896,256),(960,256),(1024,256), + (384,320),(448,320),(512,320),(576,320),(640,320),(704,320),(768,320),(832,320),(896,320),(960,320),(1024,320), + (448,384),(512,384),(576,384),(640,384),(704,384),(768,384),(832,384),(896,384),(960,384),(1024,384), + (512,448),(576,448),(640,448),(704,448),(768,448),(832,448),(896,448),(960,448),(1024,448), + (576,512),(640,512),(704,512),(768,512),(832,512),(896,512),(960,512),(1024,512), + (640,576),(704,576),(768,576),(832,576),(896,576),(960,576),(1024,576), + (704,640),(768,640),(832,640),(896,640),(960,640),(1024,640), + (768,704),(832,704),(896,704),(960,704),(1024,704), + (832,768),(896,768),(960,768),(1024,768), + (896,832),(960,832),(1024,832), + (960,896),(1024,896), + (1024,960) ); $crate::macro_repeated!( impl_widen_not_const_generic,(), (1,2), (1,3),(2,3), - (1,4),(2,4),(3,4), - (1,5),(2,5),(3,5),(4,5), - (1,6),(2,6),(3,6),(4,6),(5,6), - (1,7),(2,7),(3,7),(4,7),(5,7),(6,7), - (1,8),(2,8),(3,8),(4,8),(5,8),(6,8),(7,8), - (1,9),(2,9),(3,9),(4,9),(5,9),(6,9),(7,9),(8,9), - (1,10),(2,10),(3,10),(4,10),(5,10),(6,10),(7,10),(8,10),(9,10), - (1,11),(2,11),(3,11),(4,11),(5,11),(6,11),(7,11),(8,11),(9,11),(10,11), - (1,12),(2,12),(3,12),(4,12),(5,12),(6,12),(7,12),(8,12),(9,12),(10,12),(11,12), - (1,13),(2,13),(3,13),(4,13),(5,13),(6,13),(7,13),(8,13),(9,13),(10,13),(11,13),(12,13), - (1,14),(2,14),(3,14),(4,14),(5,14),(6,14),(7,14),(8,14),(9,14),(10,14),(11,14),(12,14),(13,14), - (1,15),(2,15),(3,15),(4,15),(5,15),(6,15),(7,15),(8,15),(9,15),(10,15),(11,15),(12,15),(13,15),(14,15), - (1,16),(2,16),(3,16),(4,16),(5,16),(6,16),(7,16),(8,16),(9,16),(10,16),(11,16),(12,16),(13,16),(14,16),(15,16), - (1,17) + (1,256),(2,256),(3,256), + (1,320),(2,320),(3,320),(256,320), + (1,384),(2,384),(3,384),(256,384),(320,384), + (1,448),(2,448),(3,448),(256,448),(320,448),(384,448), + (1,512),(2,512),(3,512),(256,512),(320,512),(384,512),(448,512), + (1,576),(2,576),(3,576),(256,576),(320,576),(384,576),(448,576),(512,576), + (1,640),(2,640),(3,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), + (1,704),(2,704),(3,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), + (1,768),(2,768),(3,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), + (1,832),(2,832),(3,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (1,896),(2,896),(3,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (1,960),(2,960),(3,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(2,1024),(3,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (1,1088) ); impl,U> fixed_wide::fixed::Wrap> for Vector { -- 2.49.1 From fd1200006122044fec98a6878cf9209304a21457 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:58:19 -0700 Subject: [PATCH 41/86] 3 --- lib/linear_ops/src/macros/fixed_wide.rs | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/linear_ops/src/macros/fixed_wide.rs b/lib/linear_ops/src/macros/fixed_wide.rs index a914532d..3bd8e6bb 100644 --- a/lib/linear_ops/src/macros/fixed_wide.rs +++ b/lib/linear_ops/src/macros/fixed_wide.rs @@ -27,7 +27,7 @@ macro_rules! impl_fixed_wide_vector_not_const_generic { #[macro_export(local_inner_macros)] macro_rules! macro_4 { ( $macro: ident, $any:tt ) => { - $crate::macro_repeated!($macro,$any,1,2,3,256); + $crate::macro_repeated!($macro,$any,1,2,192,256); } } @@ -39,9 +39,9 @@ macro_rules! impl_fixed_wide_vector { // I LOVE NOT BEING ABLE TO USE CONST GENERICS $crate::macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(3,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), - (3,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), - (256,3),(320,3),(384,3),(448,3),(512,3),(576,3),(640,3),(704,3),(768,3),(832,3),(896,3),(960,3),(1024,3), + (2,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (192,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (256,192),(320,192),(384,192),(448,192),(512,192),(576,192),(640,192),(704,192),(768,192),(832,192),(896,192),(960,192),(1024,192), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256),(832,256),(896,256),(960,256),(1024,256), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320),(768,320),(832,320),(896,320),(960,320),(1024,320), (448,384),(512,384),(576,384),(640,384),(704,384),(768,384),(832,384),(896,384),(960,384),(1024,384), @@ -58,20 +58,20 @@ macro_rules! impl_fixed_wide_vector { $crate::macro_repeated!( impl_widen_not_const_generic,(), (1,2), - (1,3),(2,3), - (1,256),(2,256),(3,256), - (1,320),(2,320),(3,320),(256,320), - (1,384),(2,384),(3,384),(256,384),(320,384), - (1,448),(2,448),(3,448),(256,448),(320,448),(384,448), - (1,512),(2,512),(3,512),(256,512),(320,512),(384,512),(448,512), - (1,576),(2,576),(3,576),(256,576),(320,576),(384,576),(448,576),(512,576), - (1,640),(2,640),(3,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), - (1,704),(2,704),(3,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), - (1,768),(2,768),(3,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), - (1,832),(2,832),(3,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), - (1,896),(2,896),(3,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), - (1,960),(2,960),(3,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(2,1024),(3,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (1,192),(2,192), + (1,256),(2,256),(192,256), + (1,320),(2,320),(192,320),(256,320), + (1,384),(2,384),(192,384),(256,384),(320,384), + (1,448),(2,448),(192,448),(256,448),(320,448),(384,448), + (1,512),(2,512),(192,512),(256,512),(320,512),(384,512),(448,512), + (1,576),(2,576),(192,576),(256,576),(320,576),(384,576),(448,576),(512,576), + (1,640),(2,640),(192,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), + (1,704),(2,704),(192,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), + (1,768),(2,768),(192,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), + (1,832),(2,832),(192,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (1,896),(2,896),(192,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (1,960),(2,960),(192,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(2,1024),(192,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), (1,1088) ); impl,U> fixed_wide::fixed::Wrap> for Vector -- 2.49.1 From 09d2965d2ef2bcc8cf2a17daacb4f0a24ac0b37c Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:58:32 -0700 Subject: [PATCH 42/86] 2 --- lib/linear_ops/src/macros/fixed_wide.rs | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/linear_ops/src/macros/fixed_wide.rs b/lib/linear_ops/src/macros/fixed_wide.rs index 3bd8e6bb..998c1fbd 100644 --- a/lib/linear_ops/src/macros/fixed_wide.rs +++ b/lib/linear_ops/src/macros/fixed_wide.rs @@ -27,7 +27,7 @@ macro_rules! impl_fixed_wide_vector_not_const_generic { #[macro_export(local_inner_macros)] macro_rules! macro_4 { ( $macro: ident, $any:tt ) => { - $crate::macro_repeated!($macro,$any,1,2,192,256); + $crate::macro_repeated!($macro,$any,1,128,192,256); } } @@ -39,8 +39,8 @@ macro_rules! impl_fixed_wide_vector { // I LOVE NOT BEING ABLE TO USE CONST GENERICS $crate::macro_repeated!( impl_narrow_not_const_generic,(), - (2,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), - (192,2),(256,2),(320,2),(384,2),(448,2),(512,2),(576,2),(640,2),(704,2),(768,2),(832,2),(896,2),(960,2),(1024,2), + (128,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (192,128),(256,128),(320,128),(384,128),(448,128),(512,128),(576,128),(640,128),(704,128),(768,128),(832,128),(896,128),(960,128),(1024,128), (256,192),(320,192),(384,192),(448,192),(512,192),(576,192),(640,192),(704,192),(768,192),(832,192),(896,192),(960,192),(1024,192), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256),(832,256),(896,256),(960,256),(1024,256), (384,320),(448,320),(512,320),(576,320),(640,320),(704,320),(768,320),(832,320),(896,320),(960,320),(1024,320), @@ -57,21 +57,21 @@ macro_rules! impl_fixed_wide_vector { ); $crate::macro_repeated!( impl_widen_not_const_generic,(), - (1,2), - (1,192),(2,192), - (1,256),(2,256),(192,256), - (1,320),(2,320),(192,320),(256,320), - (1,384),(2,384),(192,384),(256,384),(320,384), - (1,448),(2,448),(192,448),(256,448),(320,448),(384,448), - (1,512),(2,512),(192,512),(256,512),(320,512),(384,512),(448,512), - (1,576),(2,576),(192,576),(256,576),(320,576),(384,576),(448,576),(512,576), - (1,640),(2,640),(192,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), - (1,704),(2,704),(192,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), - (1,768),(2,768),(192,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), - (1,832),(2,832),(192,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), - (1,896),(2,896),(192,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), - (1,960),(2,960),(192,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(2,1024),(192,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (1,128), + (1,192),(128,192), + (1,256),(128,256),(192,256), + (1,320),(128,320),(192,320),(256,320), + (1,384),(128,384),(192,384),(256,384),(320,384), + (1,448),(128,448),(192,448),(256,448),(320,448),(384,448), + (1,512),(128,512),(192,512),(256,512),(320,512),(384,512),(448,512), + (1,576),(128,576),(192,576),(256,576),(320,576),(384,576),(448,576),(512,576), + (1,640),(128,640),(192,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), + (1,704),(128,704),(192,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), + (1,768),(128,768),(192,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), + (1,832),(128,832),(192,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (1,896),(128,896),(192,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (1,960),(128,960),(192,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (1,1024),(128,1024),(192,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), (1,1088) ); impl,U> fixed_wide::fixed::Wrap> for Vector -- 2.49.1 From f4e3c441f892fe9e8b510b42788c5d4401933fee Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 08:58:48 -0700 Subject: [PATCH 43/86] 1 --- lib/linear_ops/src/macros/fixed_wide.rs | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/linear_ops/src/macros/fixed_wide.rs b/lib/linear_ops/src/macros/fixed_wide.rs index 998c1fbd..851e5b4a 100644 --- a/lib/linear_ops/src/macros/fixed_wide.rs +++ b/lib/linear_ops/src/macros/fixed_wide.rs @@ -27,7 +27,7 @@ macro_rules! impl_fixed_wide_vector_not_const_generic { #[macro_export(local_inner_macros)] macro_rules! macro_4 { ( $macro: ident, $any:tt ) => { - $crate::macro_repeated!($macro,$any,1,128,192,256); + $crate::macro_repeated!($macro,$any,64,128,192,256); } } @@ -39,7 +39,7 @@ macro_rules! impl_fixed_wide_vector { // I LOVE NOT BEING ABLE TO USE CONST GENERICS $crate::macro_repeated!( impl_narrow_not_const_generic,(), - (128,1),(192,1),(256,1),(320,1),(384,1),(448,1),(512,1),(576,1),(640,1),(704,1),(768,1),(832,1),(896,1),(960,1),(1024,1),(1088,1), + (128,64),(192,64),(256,64),(320,64),(384,64),(448,64),(512,64),(576,64),(640,64),(704,64),(768,64),(832,64),(896,64),(960,64),(1024,64),(1088,64), (192,128),(256,128),(320,128),(384,128),(448,128),(512,128),(576,128),(640,128),(704,128),(768,128),(832,128),(896,128),(960,128),(1024,128), (256,192),(320,192),(384,192),(448,192),(512,192),(576,192),(640,192),(704,192),(768,192),(832,192),(896,192),(960,192),(1024,192), (320,256),(384,256),(448,256),(512,256),(576,256),(640,256),(704,256),(768,256),(832,256),(896,256),(960,256),(1024,256), @@ -57,22 +57,22 @@ macro_rules! impl_fixed_wide_vector { ); $crate::macro_repeated!( impl_widen_not_const_generic,(), - (1,128), - (1,192),(128,192), - (1,256),(128,256),(192,256), - (1,320),(128,320),(192,320),(256,320), - (1,384),(128,384),(192,384),(256,384),(320,384), - (1,448),(128,448),(192,448),(256,448),(320,448),(384,448), - (1,512),(128,512),(192,512),(256,512),(320,512),(384,512),(448,512), - (1,576),(128,576),(192,576),(256,576),(320,576),(384,576),(448,576),(512,576), - (1,640),(128,640),(192,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), - (1,704),(128,704),(192,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), - (1,768),(128,768),(192,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), - (1,832),(128,832),(192,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), - (1,896),(128,896),(192,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), - (1,960),(128,960),(192,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), - (1,1024),(128,1024),(192,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), - (1,1088) + (64,128), + (64,192),(128,192), + (64,256),(128,256),(192,256), + (64,320),(128,320),(192,320),(256,320), + (64,384),(128,384),(192,384),(256,384),(320,384), + (64,448),(128,448),(192,448),(256,448),(320,448),(384,448), + (64,512),(128,512),(192,512),(256,512),(320,512),(384,512),(448,512), + (64,576),(128,576),(192,576),(256,576),(320,576),(384,576),(448,576),(512,576), + (64,640),(128,640),(192,640),(256,640),(320,640),(384,640),(448,640),(512,640),(576,640), + (64,704),(128,704),(192,704),(256,704),(320,704),(384,704),(448,704),(512,704),(576,704),(640,704), + (64,768),(128,768),(192,768),(256,768),(320,768),(384,768),(448,768),(512,768),(576,768),(640,768),(704,768), + (64,832),(128,832),(192,832),(256,832),(320,832),(384,832),(448,832),(512,832),(576,832),(640,832),(704,832),(768,832), + (64,896),(128,896),(192,896),(256,896),(320,896),(384,896),(448,896),(512,896),(576,896),(640,896),(704,896),(768,896),(832,896), + (64,960),(128,960),(192,960),(256,960),(320,960),(384,960),(448,960),(512,960),(576,960),(640,960),(704,960),(768,960),(832,960),(896,960), + (64,1024),(128,1024),(192,1024),(256,1024),(320,1024),(384,1024),(448,1024),(512,1024),(576,1024),(640,1024),(704,1024),(768,1024),(832,1024),(896,1024),(960,1024), + (64,1088) ); impl,U> fixed_wide::fixed::Wrap> for Vector { -- 2.49.1 From bce57bcaff571c77ba32be9518f28335dfaa964c Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 09:00:35 -0700 Subject: [PATCH 44/86] fix --- engine/physics/src/minimum_difference.rs | 12 ++++++------ lib/common/src/aabb.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engine/physics/src/minimum_difference.rs b/engine/physics/src/minimum_difference.rs index f86e6a1c..9aff4e38 100644 --- a/engine/physics/src/minimum_difference.rs +++ b/engine/physics/src/minimum_difference.rs @@ -105,9 +105,9 @@ fn narrow_dir2(dir:Vector3)->Planar64Vec3{ if dir==vec3::zero(){ return dir.narrow_64().unwrap(); } - let x=dir.x.as_bits().unsigned_abs().bits(); - let y=dir.y.as_bits().unsigned_abs().bits(); - let z=dir.z.as_bits().unsigned_abs().bits(); + let x=dir.x.as_bits().unsigned_abs().bit_width(); + let y=dir.y.as_bits().unsigned_abs().bit_width(); + let z=dir.z.as_bits().unsigned_abs().bit_width(); let big=x.max(y).max(z); const MAX_BITS:u32=64+31; if MAX_BITS)->Planar64Vec3{ if dir==vec3::zero(){ return dir.narrow_64().unwrap(); } - let x=dir.x.as_bits().unsigned_abs().bits(); - let y=dir.y.as_bits().unsigned_abs().bits(); - let z=dir.z.as_bits().unsigned_abs().bits(); + let x=dir.x.as_bits().unsigned_abs().bit_width(); + let y=dir.y.as_bits().unsigned_abs().bit_width(); + let z=dir.z.as_bits().unsigned_abs().bit_width(); let big=x.max(y).max(z); const MAX_BITS:u32=96+31; if MAX_BITSfixed_wide::fixed::F128_64{ + pub fn area_weight(&self)->fixed_wide::types::F128_64{ let d=self.max-self.min; d.x*d.y+d.y*d.z+d.z*d.x } -- 2.49.1 From 37a086405a979fc6c6a365b0843897d0743f4035 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 09:02:24 -0700 Subject: [PATCH 45/86] lints --- engine/physics/src/face_crawler.rs | 2 +- lib/common/src/integer.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/physics/src/face_crawler.rs b/engine/physics/src/face_crawler.rs index 1fec10d2..2d3ad74d 100644 --- a/engine/physics/src/face_crawler.rs +++ b/engine/physics/src/face_crawler.rs @@ -1,7 +1,7 @@ use crate::model::{into_giga_time,GigaTime}; use strafesnet_common::integer::fixed_types::{F64_32,F128_64,F256_128}; use strafesnet_common::integer::vec3::Vector3; -use strafesnet_common::integer::{Fixed,Ratio,Planar64Vec3}; +use strafesnet_common::integer::{Ratio,Planar64Vec3}; use crate::physics::{Time,Trajectory}; use crate::mesh_query::{FEV,DirectedEdge,MeshQuery,MeshTopology}; diff --git a/lib/common/src/integer.rs b/lib/common/src/integer.rs index 9579bbb0..dd875228 100644 --- a/lib/common/src/integer.rs +++ b/lib/common/src/integer.rs @@ -5,7 +5,7 @@ pub mod fixed_types{ pub use fixed_wide::types::*; } -use fixed_wide::types::{F64_32,F128_64}; +use fixed_wide::types::F128_64; //integer units @@ -183,6 +183,7 @@ impl From> for f64{ #[cfg(test)] mod test_time{ use super::*; + use fixed_wide::types::F64_32; type Time=AbsoluteTime; #[test] fn time_from_planar64(){ -- 2.49.1 From 651038fa47287e791f0dec808f81d5a692f38ef7 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 09:03:31 -0700 Subject: [PATCH 46/86] fix --- lib/fixed_wide/src/fixed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 32ab3f36..a89af54b 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -47,7 +47,7 @@ impl Fixed{ let mut digits=Self::ZERO; let bytes=value.to_ne_bytes(); let mut digit=0; - while digit Date: Fri, 20 Mar 2026 09:13:31 -0700 Subject: [PATCH 47/86] nothing --- lib/fixed_wide/src/fixed.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index a89af54b..575f87e8 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -268,30 +268,29 @@ macro_rules! impl_from_float{ // the 53 bit mantissa has room to shift by 0-7 bits let aligned_mantissa=m<>DIGIT_SHIFT; - let mut i_d=0; - while i_m>DIGIT_SHIFT; + i_d=0; }else{ + // f32 -> 19 bit too big + // f64 -> 48 bits too big // lsb of mantissa is higher than lsb of fixed point // [0,0,0,0]<>DIGIT_SHIFT; - while i_m>DIGIT_SHIFT; + } + while i_m Date: Fri, 20 Mar 2026 09:27:58 -0700 Subject: [PATCH 48/86] fix from_f32 --- lib/fixed_wide/src/fixed.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 575f87e8..6bb6f65a 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -256,27 +256,27 @@ macro_rules! impl_from_float{ =>{ let (m,e,s)=$decode(value); let mut digits=[0u8;N]; - let lsb_biased=e as usize+F; - if lsb_biased+$mantissa_bits<$bias{ + let lsb_biased=e as usize+F+1; + if lsb_biased<$bias{ return Err(FixedFromFloatError::Underflow); }; - if N*BNUM_DIGIT_WIDTH+$bias<=lsb_biased{ + if N*BNUM_DIGIT_WIDTH+$bias+$mantissa_bits<=lsb_biased{ return Err(FixedFromFloatError::Overflow); } // underflow is ok, we only need to know the alignment - let lsb_alignment=lsb_biased.wrapping_sub($bias)&((1<>DIGIT_SHIFT; + i_m=(($bias+$mantissa_bits)-lsb_biased)>>DIGIT_SHIFT; i_d=0; }else{ // f32 -> 19 bit too big @@ -285,7 +285,7 @@ macro_rules! impl_from_float{ // [0,0,0,0]<>DIGIT_SHIFT; + i_d=(lsb_biased-($bias+$mantissa_bits))>>DIGIT_SHIFT; } while i_m Date: Fri, 20 Mar 2026 09:28:44 -0700 Subject: [PATCH 49/86] Revert "shut up pls" This reverts commit afd7db8c9021e7b837a697eb3494b3ed0af23f5a. --- lib/fixed_wide/src/fixed.rs | 69 ++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 6bb6f65a..2812cb97 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -154,41 +154,40 @@ macro_rules! impl_into_float{ impl Into<$output> for Fixed{ #[inline] fn into(self)->$output{ - panic!() - // const DIGIT_SHIFT:u32=BNUM_DIGIT_WIDTH.ilog2(); - // // SBBB BBBB - // // 1001 1110 0000 0000 - // let sign=if self.bits.is_negative(){(1 as $unsigned)<<(<$unsigned>::BITS-1)}else{0}; - // let unsigned=self.bits.unsigned_abs(); - // let most_significant_bit=unsigned.bit_width(); - // let exp=if unsigned.is_zero(){ - // 0 - // }else{ - // let msb=most_significant_bit as $unsigned; - // let msb_offset=msb+$bias-1-F as $unsigned; - // msb_offset<<($mantissa_bits-1) - // }; - // let digits=unsigned.to_bytes(); - // let digit_index=most_significant_bit.saturating_sub(1)>>DIGIT_SHIFT; - // let digit=digits[digit_index as usize]; - // //How many bits does the mantissa take from this digit - // let take_bits=most_significant_bit-(digit_index<::from_bits(bits) + const DIGIT_SHIFT:u32=BNUM_DIGIT_WIDTH.ilog2(); + // SBBB BBBB + // 1001 1110 0000 0000 + let sign=if self.bits.is_negative(){(1 as $unsigned)<<(<$unsigned>::BITS-1)}else{0}; + let unsigned=self.bits.unsigned_abs(); + let most_significant_bit=unsigned.bit_width(); + let exp=if unsigned.is_zero(){ + 0 + }else{ + let msb=most_significant_bit as $unsigned; + let msb_offset=msb+$bias-1-F as $unsigned; + msb_offset<<($mantissa_bits-1) + }; + let digits=unsigned.to_bytes(); + let digit_index=most_significant_bit.saturating_sub(1)>>DIGIT_SHIFT; + let digit=digits[digit_index as usize]; + //How many bits does the mantissa take from this digit + let take_bits=most_significant_bit-(digit_index<::from_bits(bits) } } } -- 2.49.1 From ca99da83eb78619fae24eb3bd7a143d6f36b2fd1 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 10:01:55 -0700 Subject: [PATCH 50/86] attempt impl_into_float --- lib/fixed_wide/src/fixed.rs | 48 ++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 2812cb97..a6f096ae 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -155,11 +155,9 @@ macro_rules! impl_into_float{ #[inline] fn into(self)->$output{ const DIGIT_SHIFT:u32=BNUM_DIGIT_WIDTH.ilog2(); - // SBBB BBBB - // 1001 1110 0000 0000 let sign=if self.bits.is_negative(){(1 as $unsigned)<<(<$unsigned>::BITS-1)}else{0}; let unsigned=self.bits.unsigned_abs(); - let most_significant_bit=unsigned.bit_width(); + let most_significant_bit=unsigned.bit_width() as usize; let exp=if unsigned.is_zero(){ 0 }else{ @@ -168,24 +166,36 @@ macro_rules! impl_into_float{ msb_offset<<($mantissa_bits-1) }; let digits=unsigned.to_bytes(); + // saturating_sub for 0, unrelated to exp code that handles 0 in a different way let digit_index=most_significant_bit.saturating_sub(1)>>DIGIT_SHIFT; - let digit=digits[digit_index as usize]; - //How many bits does the mantissa take from this digit - let take_bits=most_significant_bit-(digit_index<>DIGIT_SHIFT; + i_d=0; + }else{ + // lsb of mantissa is higher than lsb of fixed point + // [0,0,0,1,0,0,0,0] + // [0,0,0,0]<>DIGIT_SHIFT; } - let mant=unmasked_mant&((1 as $unsigned)<<($mantissa_bits-1))-1; + while i_m::from_le_bytes(m_bytes)>>down_shift; + let mant=mant_unmasked&(((1 as $unsigned)<<($mantissa_bits-1))-1); let bits=sign|exp|mant; <$output>::from_bits(bits) } -- 2.49.1 From 3143ec06ace62612d32e2de32618cfb536c763d6 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 10:06:56 -0700 Subject: [PATCH 51/86] fix --- lib/fixed_wide/src/fixed.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index a6f096ae..f6b11e0a 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -176,17 +176,17 @@ macro_rules! impl_into_float{ let mut i_m; let mut i_d; if most_significant_bit<$mantissa_bits{ - // lsb of mantissa is lower than lsb of fixed point - // [0,0,0,1,0,0,0,0] - // [0,0,0,0]<>DIGIT_SHIFT; - i_d=0; - }else{ // lsb of mantissa is higher than lsb of fixed point // [0,0,0,1,0,0,0,0] // [0,0,0,0]<>DIGIT_SHIFT; + }else{ + // lsb of mantissa is lower than lsb of fixed point + // [0,0,0,1,0,0,0,0] + // [0,0,0,0]<>DIGIT_SHIFT; + i_d=0; } while i_m Date: Fri, 20 Mar 2026 10:13:35 -0700 Subject: [PATCH 52/86] fix lint --- lib/bsp_loader/src/brush.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bsp_loader/src/brush.rs b/lib/bsp_loader/src/brush.rs index 9a5f9ec5..ba883f5b 100644 --- a/lib/bsp_loader/src/brush.rs +++ b/lib/bsp_loader/src/brush.rs @@ -1,7 +1,7 @@ use strafesnet_common::{model,integer}; use strafesnet_common::integer::fixed_types::F192_96; use strafesnet_common::integer::vec3::Vector3; -use strafesnet_common::integer::{Fixed,Planar64,Planar64Vec3,Ratio}; +use strafesnet_common::integer::{Planar64,Planar64Vec3,Ratio}; use crate::{valve_transform_normal,valve_transform_dist}; -- 2.49.1 From c2542e3d44e875b3508ab2e5e73693f90fd06dd2 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 10:18:19 -0700 Subject: [PATCH 53/86] ai --- lib/fixed_wide/src/fixed.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index f6b11e0a..efd0dac1 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -301,6 +301,26 @@ macro_rules! impl_from_float{ i_m+=1; i_d+=1; } + + /* AI idea is not bad + // Calculate i_m and i_d without branching + // is_less is 1 if lsb_biased < bias + mantissa_bits (mantissa is "above" fixed point) + let is_less = (lsb_biased < ($bias + $mantissa_bits)) as usize; + + // If lsb < bias, we skip i_m bytes in m_bytes, i_d is 0 + // If lsb >= bias, i_m is 0, we skip i_d bytes in digits + i_m = (((($bias + $mantissa_bits) - lsb_biased) >> DIGIT_SHIFT) & is_less); + i_d = ((lsb_biased.wrapping_sub($bias + $mantissa_bits) >> DIGIT_SHIFT) & !is_less); + + // Calculate how many bytes to copy safely + let m_bytes_len = m_bytes.len(); + let count = (m_bytes_len.saturating_sub(i_m)).min(N.saturating_sub(i_d)); + + if count > 0 { + digits[i_d..i_d + count].copy_from_slice(&m_bytes[i_m..i_m + count]); + } + */ + let bits=Int::from_bytes(digits); Ok(if s{ Self::from_bits(bits.overflowing_neg().0) -- 2.49.1 From 865ef48e8873b8c660498a06f4021fdb78f72e09 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 10:35:49 -0700 Subject: [PATCH 54/86] fix --- lib/fixed_wide/src/fixed.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index efd0dac1..21bea734 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -175,17 +175,17 @@ macro_rules! impl_into_float{ let mut i_m; let mut i_d; - if most_significant_bit<$mantissa_bits{ + if $mantissa_bits>DIGIT_SHIFT; + i_d=(most_significant_bit-$mantissa_bits)>>DIGIT_SHIFT; }else{ // lsb of mantissa is lower than lsb of fixed point // [0,0,0,1,0,0,0,0] // [0,0,0,0]<>DIGIT_SHIFT; + i_m=($mantissa_bits-most_significant_bit)>>DIGIT_SHIFT; i_d=0; } while i_m Date: Fri, 20 Mar 2026 10:51:48 -0700 Subject: [PATCH 55/86] add tests --- lib/fixed_wide/src/tests.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 06c70dd5..d9294979 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -8,6 +8,14 @@ fn you_can_add_numbers(){ #[test] fn to_f32(){ + let a=F64_32::from(1)>>2; + let f:f32=a.into(); + assert_eq!(f,0.25f32); + let f:f32=(-a).into(); + assert_eq!(f,-0.25f32); + let a=F64_32::MIN; + let f:f32=a.into(); + assert_eq!(f,i32::MIN as f32); let a=F512_256::from(1)>>2; let f:f32=a.into(); assert_eq!(f,0.25f32); @@ -23,6 +31,14 @@ fn to_f32(){ #[test] fn to_f64(){ + let a=F64_32::from(1)>>2; + let f:f64=a.into(); + assert_eq!(f,0.25f64); + let f:f64=(-a).into(); + assert_eq!(f,-0.25f64); + let a=F64_32::MIN; + let f:f64=a.into(); + assert_eq!(f,i32::MIN as f64); let a=F512_256::from(1)>>2; let f:f64=a.into(); assert_eq!(f,0.25f64); @@ -56,8 +72,9 @@ fn from_f32(){ assert_eq!(b,Ok(a)); //I32F32::MIN hits a special case since it's not representable as a positive signed integer //TODO: don't return an overflow because this is technically possible - let _a=F64_32::MIN; - let b:Result=Into::::into(F64_32::MIN).try_into(); + let a=F64_32::MIN; + let f:f32=a.into(); + let b:Result=f.try_into(); assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Overflow)); //16 is within the 24 bits of float precision let b:Result=Into::::into(-F64_32::MIN.widen_128()).try_into(); -- 2.49.1 From e806e567f5935314efc79473c456da8a43d0b922 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 10:56:40 -0700 Subject: [PATCH 56/86] update bnum --- Cargo.lock | 4 ++-- lib/fixed_wide/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 39b5dee0..c4f00eb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -433,9 +433,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d14a3912e1478234033344e1817fc1bdd0e8b088658922101cf9c8e5dbc96f6" +checksum = "acf40f6d425354fe40ff439c2a4a2733f583e49379eb8601a4c79e50c4a3c579" [[package]] name = "bstr" diff --git a/lib/fixed_wide/Cargo.toml b/lib/fixed_wide/Cargo.toml index 11ae338e..3264c73d 100644 --- a/lib/fixed_wide/Cargo.toml +++ b/lib/fixed_wide/Cargo.toml @@ -14,7 +14,7 @@ wide-mul=[] zeroes=["dep:arrayvec"] [dependencies] -bnum = "0.14.2" +bnum = "0.14.3" arrayvec = { version = "0.7.6", optional = true } paste = "1.0.15" ratio_ops = { workspace = true, optional = true } -- 2.49.1 From 86aae304450085afa0cd3bba43618b4d70d3f827 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 20 Mar 2026 11:01:12 -0700 Subject: [PATCH 57/86] clean up zeroes --- lib/fixed_wide/src/zeroes.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fixed_wide/src/zeroes.rs b/lib/fixed_wide/src/zeroes.rs index ac52e0de..9271707a 100644 --- a/lib/fixed_wide/src/zeroes.rs +++ b/lib/fixed_wide/src/zeroes.rs @@ -10,7 +10,7 @@ macro_rules! impl_zeroes{ pub fn zeroes2(a0:Self,a1:Self,a2:Self)->ArrayVec<::Output,2>{ let a2pos=match a2.cmp(&Self::ZERO){ Ordering::Greater=>true, - Ordering::Equal=>return ArrayVec::from_iter(Self::zeroes1(a0,a1).into_iter()), + Ordering::Equal=>return ArrayVec::from_iter(Self::zeroes1(a0,a1)), Ordering::Less=>false, }; let radicand=a1*a1-(a2*a0)<<2; @@ -22,7 +22,7 @@ macro_rules! impl_zeroes{ let planar_radicand=radicand.sqrt().[](); } //sort roots ascending and avoid taking the difference of large numbers - let zeroes=match (a2pos,Self::ZERO[(-a1-planar_radicand)/(a2<<1),(a0<<1)/(-a1-planar_radicand)], (true, false)=>[(a0<<1)/(-a1+planar_radicand),(-a1+planar_radicand)/(a2<<1)], (false,true )=>[(a0<<1)/(-a1-planar_radicand),(-a1-planar_radicand)/(a2<<1)], @@ -36,7 +36,7 @@ macro_rules! impl_zeroes{ } #[inline] pub fn zeroes1(a0:Self,a1:Self)->ArrayVec<::Output,1>{ - if a1==Self::ZERO{ + if a1.is_zero(){ ArrayVec::new_const() }else{ ArrayVec::from_iter([(-a0)/(a1)]) -- 2.49.1 From a15e9fccd9623f5f88af622a68704712f70ca20b Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Mon, 23 Mar 2026 09:42:03 -0700 Subject: [PATCH 58/86] add zero test --- lib/fixed_wide/src/tests.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index d9294979..0473fefc 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -8,6 +8,9 @@ fn you_can_add_numbers(){ #[test] fn to_f32(){ + let a=F64_32::ZERO; + let f:f32=a.into(); + assert_eq!(f,0.0f32); let a=F64_32::from(1)>>2; let f:f32=a.into(); assert_eq!(f,0.25f32); @@ -31,6 +34,9 @@ fn to_f32(){ #[test] fn to_f64(){ + let a=F64_32::ZERO; + let f:f64=a.into(); + assert_eq!(f,0.0f64); let a=F64_32::from(1)>>2; let f:f64=a.into(); assert_eq!(f,0.25f64); @@ -54,6 +60,9 @@ fn to_f64(){ #[test] fn from_f32(){ + let a=F64_32::ZERO; + let b:Result=0.0f32.try_into(); + assert_eq!(b,Ok(a)); let a=F512_256::from(1)>>2; let b:Result=0.25f32.try_into(); assert_eq!(b,Ok(a)); @@ -92,6 +101,9 @@ fn from_f32(){ #[test] fn from_f64(){ + let a=F64_32::ZERO; + let b:Result=0.0f64.try_into(); + assert_eq!(b,Ok(a)); let a=F512_256::from(1)>>2; let b:Result=0.25f64.try_into(); assert_eq!(b,Ok(a)); -- 2.49.1 From bad03d2d3506926c8783a3a74b494d0ff98b7abc Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Mon, 23 Mar 2026 10:01:45 -0700 Subject: [PATCH 59/86] megamind impl_into_float --- lib/fixed_wide/src/fixed.rs | 72 +++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 21bea734..fddc9960 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -1,6 +1,7 @@ use bnum::{Int,cast::As,n}; pub(crate)const BNUM_DIGIT_WIDTH:usize=8; +const DIGIT_SHIFT:u32=BNUM_DIGIT_WIDTH.ilog2(); #[derive(Clone,Copy,Default,Hash,PartialEq,Eq,PartialOrd,Ord)] /// A Fixed point number for which multiply operations widen the bits in the output. (when the wide-mul feature is enabled) @@ -154,47 +155,59 @@ macro_rules! impl_into_float{ impl Into<$output> for Fixed{ #[inline] fn into(self)->$output{ - const DIGIT_SHIFT:u32=BNUM_DIGIT_WIDTH.ilog2(); - let sign=if self.bits.is_negative(){(1 as $unsigned)<<(<$unsigned>::BITS-1)}else{0}; let unsigned=self.bits.unsigned_abs(); - let most_significant_bit=unsigned.bit_width() as usize; - let exp=if unsigned.is_zero(){ - 0 - }else{ - let msb=most_significant_bit as $unsigned; - let msb_offset=msb+$bias-1-F as $unsigned; - msb_offset<<($mantissa_bits-1) + // most_significant_bit is the "index" of the most significant bit. + // 0b0000_0000.msb()==0 (but we just special case return 0.0) + // 0b0000_0001.msb()==0 + // 0b1000_0000.msb()==7 + let Some(most_significant_bit)=unsigned.bit_width().checked_sub(1)else{ + return 0.0; }; + // sign + let sign=if self.bits.is_negative(){(1 as $unsigned)<<(<$unsigned>::BITS-1)}else{0}; + + // exp + let msb=most_significant_bit as $unsigned; + let msb_offset=msb+$bias-F as $unsigned; + let exp=msb_offset<<($mantissa_bits-1); + + // mant let digits=unsigned.to_bytes(); - // saturating_sub for 0, unrelated to exp code that handles 0 in a different way - let digit_index=most_significant_bit.saturating_sub(1)>>DIGIT_SHIFT; - let down_shift=most_significant_bit-(digit_index<>DIGIT_SHIFT; + // [0b0000_0001,0,0,0,0,0,0,0] + // [0,0b0001_0000,0,0,0,0,0,0]<>DIGIT_SHIFT; + let mut i_d=right_shift>>DIGIT_SHIFT; + while i_m::from_le_bytes(m_bytes)>>(right_shift&((1<>DIGIT_SHIFT; - i_d=0; - } - while i_m>DIGIT_SHIFT; + let mut i_d=0; + while i_m::from_le_bytes(m_bytes)<::from_le_bytes(m_bytes)>>down_shift; let mant=mant_unmasked&(((1 as $unsigned)<<($mantissa_bits-1))-1); let bits=sign|exp|mant; <$output>::from_bits(bits) @@ -255,7 +268,6 @@ macro_rules! impl_from_float{ type Error=FixedFromFloatError; #[inline] fn try_from(value:$input)->Result{ - const DIGIT_SHIFT:u32=BNUM_DIGIT_WIDTH.ilog2(); match value.classify(){ std::num::FpCategory::Nan=>Err(FixedFromFloatError::Nan), std::num::FpCategory::Infinite=>Err(FixedFromFloatError::Infinite), -- 2.49.1 From b4939e3d4a334d9cb179529cb0e479a080776bb9 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Mon, 23 Mar 2026 11:54:59 -0700 Subject: [PATCH 60/86] slog --- lib/fixed_wide/src/fixed.rs | 29 +++++++++++++++++------------ lib/fixed_wide/src/tests.rs | 1 + 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index fddc9960..b6f81e3e 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -151,7 +151,7 @@ impl std::iter::Sum for Fixed{ } macro_rules! impl_into_float{ - ($output:ty,$unsigned:ty,$mantissa_bits:expr,$bias:expr) => { + ($output:ty,$unsigned:ty,$mantissa_msb:expr,$bias:expr) => { impl Into<$output> for Fixed{ #[inline] fn into(self)->$output{ @@ -169,7 +169,7 @@ macro_rules! impl_into_float{ // exp let msb=most_significant_bit as $unsigned; let msb_offset=msb+$bias-F as $unsigned; - let exp=msb_offset<<($mantissa_bits-1); + let exp=msb_offset<<$mantissa_msb; // mant let digits=unsigned.to_bytes(); @@ -178,13 +178,16 @@ macro_rules! impl_into_float{ let mut m_bytes=[0u8;_]; let mant_unmasked; - /// Use a bias to ensure the top case is always a right shift and the bottom case is always a left shift + /// Use a bias to ensure the top case is always a right shift and the bottom case is always a left shift. + /// Both f32 and f64 have at least 8 bits of room in the mantissa $unsigned type. const BIAS:usize=8; - if $mantissa_bits> + let right_shift=most_significant_bit as usize-$mantissa_msb; let mut i_m=BIAS>>DIGIT_SHIFT; let mut i_d=right_shift>>DIGIT_SHIFT; while i_m::from_le_bytes(m_bytes)>>(right_shift&((1<::from_le_bytes(m_bytes); + let right_shift=((right_shift as usize+NEG_MANTISSA_ALIGNMENT)&((1<>right_shift; }else{ // lsb of mantissa is lower than lsb of fixed point // [0,0,0,0,0b0100_0000,0,0,0] // [0,0b0001_0000,0,0,0,0,0,0]<>DIGIT_SHIFT; let mut i_d=0; while i_m::from_le_bytes(m_bytes)<::from_bits(bits) } } } } -impl_into_float!(f32,u32,24,127); -impl_into_float!(f64,u64,53,1023); +impl_into_float!(f32,u32,23,127); +impl_into_float!(f64,u64,52,1023); #[inline] fn integer_decode_f32(f: f32) -> (u32, u8, bool) { diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 0473fefc..db9ecc33 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -8,6 +8,7 @@ fn you_can_add_numbers(){ #[test] fn to_f32(){ + // TODO: test the number 0b11111111_11111111 and test it multiplied by many powers of two let a=F64_32::ZERO; let f:f32=a.into(); assert_eq!(f,0.0f32); -- 2.49.1 From 9041378f48abea824e58b9219ba6d6a05d450844 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 07:07:43 -0700 Subject: [PATCH 61/86] fix fix --- lib/fixed_wide/src/fixed.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index b6f81e3e..18f453a6 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -187,7 +187,7 @@ macro_rules! impl_into_float{ // [0b0000_0010,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] // [0b0000_0010,0,0,0,0,0,0,0]<> - let right_shift=most_significant_bit as usize-$mantissa_msb; + let right_shift=most_significant_bit as usize+NEG_MANTISSA_ALIGNMENT-$mantissa_msb; let mut i_m=BIAS>>DIGIT_SHIFT; let mut i_d=right_shift>>DIGIT_SHIFT; while i_m::from_le_bytes(m_bytes); - let right_shift=((right_shift as usize+NEG_MANTISSA_ALIGNMENT)&((1<>right_shift; }else{ // lsb of mantissa is lower than lsb of fixed point -- 2.49.1 From 8e790252871556799a38d7086bc93df1189ebeb4 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 07:23:10 -0700 Subject: [PATCH 62/86] test --- lib/fixed_wide/src/tests.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index db9ecc33..83717cad 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -6,9 +6,21 @@ fn you_can_add_numbers(){ assert_eq!(a+a,F512_256::from((3i128*2).pow(4)*2)); } +fn _65535() + where + crate::fixed::Fixed:Into +{ + use crate::fixed::Fixed; + for i in 0..N-16{ + let a=(Fixed::::from_u64(65535)>>(F as u32))<<(i as u32); + let b=65535f64.powi(i as i32); + assert_eq!(a.into(),b); + assert_eq!(a,b.try_into().unwrap()); + } +} + #[test] fn to_f32(){ - // TODO: test the number 0b11111111_11111111 and test it multiplied by many powers of two let a=F64_32::ZERO; let f:f32=a.into(); assert_eq!(f,0.0f32); -- 2.49.1 From 93f65a6e93556b34282dc241d3eda7f56be2ceb5 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 07:40:13 -0700 Subject: [PATCH 63/86] test --- lib/fixed_wide/src/tests.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 83717cad..9ef15130 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -10,15 +10,21 @@ fn _65535() where crate::fixed::Fixed:Into { + // 11111111_11111111<::from_u64(65535)>>(F as u32))<<(i as u32); - let b=65535f64.powi(i as i32); - assert_eq!(a.into(),b); - assert_eq!(a,b.try_into().unwrap()); + for i in 0..N as u32*8-u16::BITS{ + let a=Fixed::from_bits(bnum::cast::As::as_::>(u16::MAX).shl(i)); + let b=(u16::MAX as f64)*2.0f64.powi(i as i32-F as i32); + assert_eq!(a.into(),b,"Into float {i}"); + assert_eq!(a,b.try_into().unwrap(),"From float {i}"); } } +#[test] +fn asdasd(){ + _65535::<{128/8},64>(); +} + #[test] fn to_f32(){ let a=F64_32::ZERO; -- 2.49.1 From 3bd7b2b21f901bbabe036803b821d0596e07e726 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 07:43:51 -0700 Subject: [PATCH 64/86] fix --- lib/fixed_wide/src/fixed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 18f453a6..95ee008c 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -210,7 +210,7 @@ macro_rules! impl_into_float{ i_m+=1; i_d+=1; } - mant_unmasked=<$unsigned>::from_le_bytes(m_bytes)<::from_le_bytes(m_bytes)<<(left_shift&((1< Date: Tue, 24 Mar 2026 07:52:40 -0700 Subject: [PATCH 65/86] don't know anything --- lib/fixed_wide/src/zeroes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/zeroes.rs b/lib/fixed_wide/src/zeroes.rs index 9271707a..321bbed7 100644 --- a/lib/fixed_wide/src/zeroes.rs +++ b/lib/fixed_wide/src/zeroes.rs @@ -13,7 +13,7 @@ macro_rules! impl_zeroes{ Ordering::Equal=>return ArrayVec::from_iter(Self::zeroes1(a0,a1)), Ordering::Less=>false, }; - let radicand=a1*a1-(a2*a0)<<2; + let radicand=a1*a1-((a2*a0)<<2); match radicand.cmp(&::Output::ZERO){ Ordering::Greater=>{ // using wrap because sqrt always halves the number of leading digits. -- 2.49.1 From 1a2f8bd0d18843001e018e1c69a94c547f2dc478 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 07:55:50 -0700 Subject: [PATCH 66/86] test 53 bits --- lib/fixed_wide/src/tests.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 9ef15130..5262bbaf 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -10,11 +10,11 @@ fn _65535() where crate::fixed::Fixed:Into { - // 11111111_11111111<>(u16::MAX).shl(i)); - let b=(u16::MAX as f64)*2.0f64.powi(i as i32-F as i32); + for i in 0..N as u32*8-53{ + let a=Fixed::from_bits(bnum::cast::As::as_::>(_53).shl(i)); + let b=(_53 as f64)*2.0f64.powi(i as i32-F as i32); assert_eq!(a.into(),b,"Into float {i}"); assert_eq!(a,b.try_into().unwrap(),"From float {i}"); } -- 2.49.1 From 636f7b2870a7e97efe072baaee5989e424eece02 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 08:04:07 -0700 Subject: [PATCH 67/86] MOD8 constant --- lib/fixed_wide/src/fixed.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 95ee008c..f2db8ddb 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -181,7 +181,8 @@ macro_rules! impl_into_float{ /// Use a bias to ensure the top case is always a right shift and the bottom case is always a left shift. /// Both f32 and f64 have at least 8 bits of room in the mantissa $unsigned type. const BIAS:usize=8; - const NEG_MANTISSA_ALIGNMENT:usize=(1<::from_le_bytes(m_bytes); - let right_shift=(right_shift&((1<>right_shift; }else{ // lsb of mantissa is lower than lsb of fixed point @@ -210,7 +211,7 @@ macro_rules! impl_into_float{ i_m+=1; i_d+=1; } - mant_unmasked=<$unsigned>::from_le_bytes(m_bytes)<<(left_shift&((1<::from_le_bytes(m_bytes)<<(left_shift&MOD8); } let mant=mant_unmasked&(((1 as $unsigned)<<$mantissa_msb)-1); -- 2.49.1 From 33398b67002e7351016eafbed3e132530dc44024 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 08:04:23 -0700 Subject: [PATCH 68/86] test many --- lib/fixed_wide/src/tests.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 5262bbaf..a2711d70 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -1,3 +1,4 @@ +use crate::fixed::Fixed; use crate::types::{F64_32,F128_64,F192_96,F512_256}; #[test] @@ -6,23 +7,25 @@ fn you_can_add_numbers(){ assert_eq!(a+a,F512_256::from((3i128*2).pow(4)*2)); } -fn _65535() +fn test_bit_by_bit() where - crate::fixed::Fixed:Into + Fixed:Into { const _53:u64=(1<<53)-1; - use crate::fixed::Fixed; for i in 0..N as u32*8-53{ let a=Fixed::from_bits(bnum::cast::As::as_::>(_53).shl(i)); let b=(_53 as f64)*2.0f64.powi(i as i32-F as i32); - assert_eq!(a.into(),b,"Into float {i}"); + assert_eq!(a.into(),b,"F{}_{F} Into float {i}",N*8); assert_eq!(a,b.try_into().unwrap(),"From float {i}"); } } #[test] -fn asdasd(){ - _65535::<{128/8},64>(); +fn test_many(){ + test_bit_by_bit::<{64/8},32>(); + test_bit_by_bit::<{128/8},64>(); + test_bit_by_bit::<{256/8},128>(); + test_bit_by_bit::<{512/8},256>(); } #[test] -- 2.49.1 From e4d6c93f03cf835f44a2020f462e124a10c78c8b Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 08:39:44 -0700 Subject: [PATCH 69/86] idiocy --- lib/fixed_wide/src/fixed.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index f2db8ddb..e555fd49 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -178,18 +178,16 @@ macro_rules! impl_into_float{ let mut m_bytes=[0u8;_]; let mant_unmasked; - /// Use a bias to ensure the top case is always a right shift and the bottom case is always a left shift. - /// Both f32 and f64 have at least 8 bits of room in the mantissa $unsigned type. - const BIAS:usize=8; const MOD8:usize=((1<> - let right_shift=most_significant_bit as usize+NEG_MANTISSA_ALIGNMENT-$mantissa_msb; - let mut i_m=BIAS>>DIGIT_SHIFT; + let right_shift=most_significant_bit as usize-$mantissa_msb; + let mut i_m=0; let mut i_d=right_shift>>DIGIT_SHIFT; while i_m::from_le_bytes(m_bytes); - let right_shift=(right_shift&MOD8)+($mantissa_msb&MOD8); + let right_shift=(right_shift&MOD8)+MANT_REM; mant_unmasked=unsigned>>right_shift; }else{ // lsb of mantissa is lower than lsb of fixed point -- 2.49.1 From 8b6f30acaa371a93db232619f5f35d9bf2a46189 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 08:39:51 -0700 Subject: [PATCH 70/86] picture --- lib/fixed_wide/src/fixed.rs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index e555fd49..ee775d68 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -183,9 +183,31 @@ macro_rules! impl_into_float{ const NEG_MANT_REM:usize=(1<> + // Copy bytes + // CASE 0: + // F64_32 [00000000,00011111,11111111,11111111,11111111,11111111,11111111,11111111] + // u64 [00011111,11111111,11111111,11111111,11111111,11111111,11111111,00000000] + // CASE 1: + // F64_32 [00000000,00111111,11111111,11111111,11111111,11111111,11111111,11111110] + // u64 [00111111,11111111,11111111,11111111,11111111,11111111,11111110,00000000] + // CASE 2: + // F64_32 [00000000,01111111,11111111,11111111,11111111,11111111,11111111,11111100] + // u64 [01111111,11111111,11111111,11111111,11111111,11111111,11111100,00000000] + // CASE 3: + // F64_32 [00000000,11111111,11111111,11111111,11111111,11111111,11111111,11111000] + // u64 [11111111,11111111,11111111,11111111,11111111,11111111,11111000,00000000] + // CASE 4: + // F64_32 [00000001,11111111,11111111,11111111,11111111,11111111,11111111,11110000] + // u64 [00000001,11111111,11111111,11111111,11111111,11111111,11111111,11110000] + // CASE 5: + // F64_32 [00000011,11111111,11111111,11111111,11111111,11111111,11111111,11100000] + // u64 [00000011,11111111,11111111,11111111,11111111,11111111,11111111,11100000] + // CASE 6: + // F64_32 [00000111,11111111,11111111,11111111,11111111,11111111,11111111,11000000] + // u64 [00000111,11111111,11111111,11111111,11111111,11111111,11111111,11000000] + // CASE 7: + // F64_32 [00001111,11111111,11111111,11111111,11111111,11111111,11111111,10000000] + // u64 [00001111,11111111,11111111,11111111,11111111,11111111,11111111,10000000] let right_shift=most_significant_bit as usize-$mantissa_msb; let mut i_m=0; let mut i_d=right_shift>>DIGIT_SHIFT; -- 2.49.1 From 4bd939e9436dabee4d446b22052ddd058c550851 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 08:56:47 -0700 Subject: [PATCH 71/86] yay yay yay YAAAAAAAAAY --- lib/fixed_wide/src/fixed.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index ee775d68..0c651434 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -181,35 +181,37 @@ macro_rules! impl_into_float{ const MOD8:usize=((1<>DIGIT_SHIFT; let mut i_d=right_shift>>DIGIT_SHIFT; while i_m::from_le_bytes(m_bytes); - let right_shift=(right_shift&MOD8)+MANT_REM; + let right_shift=((right_shift+NEG_MANT_REM)&MOD8)+MANT_REM; mant_unmasked=unsigned>>right_shift; }else{ // lsb of mantissa is lower than lsb of fixed point -- 2.49.1 From 39516ceb2b3a2d0d9bd7bf8018b1c3f158d0e72c Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 09:17:37 -0700 Subject: [PATCH 72/86] add underflow test --- lib/fixed_wide/src/tests.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index a2711d70..ab3ea1cd 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -12,12 +12,20 @@ fn test_bit_by_bit() Fixed:Into { const _53:u64=(1<<53)-1; + // all bits in range for i in 0..N as u32*8-53{ let a=Fixed::from_bits(bnum::cast::As::as_::>(_53).shl(i)); let b=(_53 as f64)*2.0f64.powi(i as i32-F as i32); assert_eq!(a.into(),b,"F{}_{F} Into float {i}",N*8); assert_eq!(a,b.try_into().unwrap(),"From float {i}"); } + // underflow + for i in 0u32..53{ + let a=Fixed::from_bits(bnum::cast::As::as_::>(_53>>i)); + let b=((_53>>i) as f64)*2.0f64.powi(-(F as i32)); + assert_eq!(a.into(),b,"Underflow F{}_{F} Into float {i}",N*8); + assert_eq!(a,b.try_into().unwrap(),"From float {i}"); + } } #[test] -- 2.49.1 From fed04e4ce4f4e76ffde32164462eeeac27b13517 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 09:25:42 -0700 Subject: [PATCH 73/86] test f32 --- lib/fixed_wide/src/tests.rs | 51 ++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index ab3ea1cd..d5022c68 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -7,33 +7,38 @@ fn you_can_add_numbers(){ assert_eq!(a+a,F512_256::from((3i128*2).pow(4)*2)); } -fn test_bit_by_bit() - where - Fixed:Into -{ - const _53:u64=(1<<53)-1; - // all bits in range - for i in 0..N as u32*8-53{ - let a=Fixed::from_bits(bnum::cast::As::as_::>(_53).shl(i)); - let b=(_53 as f64)*2.0f64.powi(i as i32-F as i32); - assert_eq!(a.into(),b,"F{}_{F} Into float {i}",N*8); - assert_eq!(a,b.try_into().unwrap(),"From float {i}"); - } - // underflow - for i in 0u32..53{ - let a=Fixed::from_bits(bnum::cast::As::as_::>(_53>>i)); - let b=((_53>>i) as f64)*2.0f64.powi(-(F as i32)); - assert_eq!(a.into(),b,"Underflow F{}_{F} Into float {i}",N*8); - assert_eq!(a,b.try_into().unwrap(),"From float {i}"); - } +const _53:u64=(1<<53)-1; +macro_rules! test_bit_by_bit{ + ($n:expr,$float:ty)=>{ + // all bits in range + for i in 0..$n-53{ + let a=Fixed::<{$n/8},{$n>>1}>::from_bits(bnum::cast::As::as_::>(_53).shl(i)); + let b=(_53 as $float)*(2.0 as $float).powi(i as i32-{$n>>1}); + let f:$float=a.into(); + assert_eq!(f,b,"F{}_{} Into float {i}",$n,$n>>1); + assert_eq!(a,b.try_into().unwrap(),"From float {i}"); + } + // underflow + for i in 0u32..53{ + let a=Fixed::<{$n/8},{$n>>1}>::from_bits(bnum::cast::As::as_::>(_53>>i)); + let b=((_53>>i) as $float)*(2.0 as $float).powi(-{$n>>1}); + let f:$float=a.into(); + assert_eq!(f,b,"Underflow F{}_{} Into float {i}",$n,$n>>1); + assert_eq!(a,b.try_into().unwrap(),"From float {i}"); + } + }; } #[test] fn test_many(){ - test_bit_by_bit::<{64/8},32>(); - test_bit_by_bit::<{128/8},64>(); - test_bit_by_bit::<{256/8},128>(); - test_bit_by_bit::<{512/8},256>(); + test_bit_by_bit!(64,f32); + test_bit_by_bit!(128,f32); + test_bit_by_bit!(256,f32); + test_bit_by_bit!(512,f32); + test_bit_by_bit!(64,f64); + test_bit_by_bit!(128,f64); + test_bit_by_bit!(256,f64); + test_bit_by_bit!(512,f64); } #[test] -- 2.49.1 From 51ed5fe2e888be1f56857605a6aa4008c02695f4 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 09:37:31 -0700 Subject: [PATCH 74/86] test fewer fits in f32 --- lib/fixed_wide/src/tests.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index d5022c68..4e4a82fb 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -7,38 +7,38 @@ fn you_can_add_numbers(){ assert_eq!(a+a,F512_256::from((3i128*2).pow(4)*2)); } -const _53:u64=(1<<53)-1; macro_rules! test_bit_by_bit{ - ($n:expr,$float:ty)=>{ + ($n:expr,$float:ty,$mantissa_bits:expr)=>{{ + const MANT:u64=(1<<$mantissa_bits)-1; // all bits in range - for i in 0..$n-53{ - let a=Fixed::<{$n/8},{$n>>1}>::from_bits(bnum::cast::As::as_::>(_53).shl(i)); - let b=(_53 as $float)*(2.0 as $float).powi(i as i32-{$n>>1}); + for i in 0..$n-$mantissa_bits{ + let a=Fixed::<{$n/8},{$n>>1}>::from_bits(bnum::cast::As::as_::>(MANT).shl(i)); + let b=(MANT as $float)*(2.0 as $float).powi(i as i32-{$n>>1}); let f:$float=a.into(); assert_eq!(f,b,"F{}_{} Into float {i}",$n,$n>>1); assert_eq!(a,b.try_into().unwrap(),"From float {i}"); } // underflow - for i in 0u32..53{ - let a=Fixed::<{$n/8},{$n>>1}>::from_bits(bnum::cast::As::as_::>(_53>>i)); - let b=((_53>>i) as $float)*(2.0 as $float).powi(-{$n>>1}); + for i in 0u32..$mantissa_bits{ + let a=Fixed::<{$n/8},{$n>>1}>::from_bits(bnum::cast::As::as_::>(MANT>>i)); + let b=((MANT>>i) as $float)*(2.0 as $float).powi(-{$n>>1}); let f:$float=a.into(); assert_eq!(f,b,"Underflow F{}_{} Into float {i}",$n,$n>>1); assert_eq!(a,b.try_into().unwrap(),"From float {i}"); } - }; + }}; } #[test] fn test_many(){ - test_bit_by_bit!(64,f32); - test_bit_by_bit!(128,f32); - test_bit_by_bit!(256,f32); - test_bit_by_bit!(512,f32); - test_bit_by_bit!(64,f64); - test_bit_by_bit!(128,f64); - test_bit_by_bit!(256,f64); - test_bit_by_bit!(512,f64); + test_bit_by_bit!(64,f32,23); + test_bit_by_bit!(128,f32,23); + test_bit_by_bit!(256,f32,23); + test_bit_by_bit!(512,f32,23); + test_bit_by_bit!(64,f64,53); + test_bit_by_bit!(128,f64,53); + test_bit_by_bit!(256,f64,53); + test_bit_by_bit!(512,f64,53); } #[test] -- 2.49.1 From de0b47a19d757444f0aec8d9829f756d6e839538 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 09:37:52 -0700 Subject: [PATCH 75/86] draw picture for f32 --- lib/fixed_wide/src/fixed.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 0c651434..20ef0749 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -183,7 +183,7 @@ macro_rules! impl_into_float{ const NEG_MANT_REM:usize=(1<>DIGIT_SHIFT; let mut i_d=right_shift>>DIGIT_SHIFT; -- 2.49.1 From 34c04e2bf2f0cac5b127a4c68271605d978179bd Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 09:40:16 -0700 Subject: [PATCH 76/86] fix test --- lib/fixed_wide/src/tests.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 4e4a82fb..77410548 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -31,10 +31,10 @@ macro_rules! test_bit_by_bit{ #[test] fn test_many(){ - test_bit_by_bit!(64,f32,23); - test_bit_by_bit!(128,f32,23); - test_bit_by_bit!(256,f32,23); - test_bit_by_bit!(512,f32,23); + test_bit_by_bit!(64,f32,24); + test_bit_by_bit!(128,f32,24); + test_bit_by_bit!(256,f32,24); + test_bit_by_bit!(512,f32,24); test_bit_by_bit!(64,f64,53); test_bit_by_bit!(128,f64,53); test_bit_by_bit!(256,f64,53); -- 2.49.1 From 6a0610a45099193b2e3591119782c1c19b5d20bd Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 09:48:53 -0700 Subject: [PATCH 77/86] fix into f32 --- lib/fixed_wide/src/fixed.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 20ef0749..97e4e8f6 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -239,7 +239,7 @@ macro_rules! impl_into_float{ // F64_32 [00111111,11111111,11111111,10000000,...] // u32 [00111111,11111111,11111111,10000000] let right_shift=most_significant_bit as usize-$mantissa_msb; - let mut i_m=((most_significant_bit as usize&MOD8)+MANT_REM)>>DIGIT_SHIFT; + let mut i_m=((most_significant_bit as usize&MOD8)+NEG_MANT_REM)>>DIGIT_SHIFT; let mut i_d=right_shift>>DIGIT_SHIFT; while i_m::from_le_bytes(m_bytes); - let right_shift=((right_shift+NEG_MANT_REM)&MOD8)+MANT_REM; + let right_shift=((right_shift+MANT_REM)&MOD8)+NEG_MANT_REM; mant_unmasked=unsigned>>right_shift; }else{ // lsb of mantissa is lower than lsb of fixed point -- 2.49.1 From 0c1d80bbea29cd91c9802074e5ff87c0701798fc Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 09:49:35 -0700 Subject: [PATCH 78/86] don't test big f32 --- lib/fixed_wide/src/tests.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 77410548..cb543607 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -33,8 +33,9 @@ macro_rules! test_bit_by_bit{ fn test_many(){ test_bit_by_bit!(64,f32,24); test_bit_by_bit!(128,f32,24); - test_bit_by_bit!(256,f32,24); - test_bit_by_bit!(512,f32,24); + // f32 is reaching its limits here + // test_bit_by_bit!(256,f32,24); + // test_bit_by_bit!(512,f32,24); test_bit_by_bit!(64,f64,53); test_bit_by_bit!(128,f64,53); test_bit_by_bit!(256,f64,53); -- 2.49.1 From b518658086b950ef758d40f8464a2a97c42b8839 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 10:00:02 -0700 Subject: [PATCH 79/86] print in test better --- lib/fixed_wide/src/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index cb543607..ab90410f 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -16,7 +16,7 @@ macro_rules! test_bit_by_bit{ let b=(MANT as $float)*(2.0 as $float).powi(i as i32-{$n>>1}); let f:$float=a.into(); assert_eq!(f,b,"F{}_{} Into float {i}",$n,$n>>1); - assert_eq!(a,b.try_into().unwrap(),"From float {i}"); + assert_eq!(a,b.try_into().unwrap(),"F{}_{} From float {i}",$n,$n>>1); } // underflow for i in 0u32..$mantissa_bits{ @@ -24,7 +24,7 @@ macro_rules! test_bit_by_bit{ let b=((MANT>>i) as $float)*(2.0 as $float).powi(-{$n>>1}); let f:$float=a.into(); assert_eq!(f,b,"Underflow F{}_{} Into float {i}",$n,$n>>1); - assert_eq!(a,b.try_into().unwrap(),"From float {i}"); + assert_eq!(a,b.try_into().unwrap(),"Underflow F{}_{} From float {i}",$n,$n>>1); } }}; } -- 2.49.1 From 8d4e17499d6d51103ddf6b22d8706d4e2ccba1b6 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 10:16:00 -0700 Subject: [PATCH 80/86] stupid code that passes tests --- lib/fixed_wide/src/fixed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 97e4e8f6..3ace91ab 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -353,7 +353,7 @@ macro_rules! impl_from_float{ // [0,0,0,1,0,0,0,0] // solve lsb_biased+BNUM_DIGIT_WIDTH*i-$bias==0 for i // i==($bias-lsb_biased)/BNUM_DIGIT_WIDTH - i_m=(($bias+$mantissa_bits)-lsb_biased)>>DIGIT_SHIFT; + i_m=(($bias+$mantissa_bits)-lsb_biased+((1<>DIGIT_SHIFT; i_d=0; }else{ // f32 -> 19 bit too big -- 2.49.1 From a4fcbe620486781a16148e2a425e955ef6c4689d Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 10:20:55 -0700 Subject: [PATCH 81/86] less stupid code --- lib/fixed_wide/src/fixed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 3ace91ab..3bad4d02 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -353,7 +353,7 @@ macro_rules! impl_from_float{ // [0,0,0,1,0,0,0,0] // solve lsb_biased+BNUM_DIGIT_WIDTH*i-$bias==0 for i // i==($bias-lsb_biased)/BNUM_DIGIT_WIDTH - i_m=(($bias+$mantissa_bits)-lsb_biased+((1<>DIGIT_SHIFT; + i_m=-((lsb_biased as isize-($bias+$mantissa_bits))>>DIGIT_SHIFT) as usize; i_d=0; }else{ // f32 -> 19 bit too big -- 2.49.1 From 2b75dac7a112f897141774e88f4f9fbd98d8f5b1 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 10:29:49 -0700 Subject: [PATCH 82/86] refactor impl_from_float to use signed ints --- lib/fixed_wide/src/fixed.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 3bad4d02..04f79d1f 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -333,36 +333,33 @@ macro_rules! impl_from_float{ =>{ let (m,e,s)=$decode(value); let mut digits=[0u8;N]; - let lsb_biased=e as usize+F+1; - if lsb_biased<$bias{ + let lsb=e as isize+F as isize+1-$bias-$mantissa_bits; + if lsb+$mantissa_bits<0{ return Err(FixedFromFloatError::Underflow); }; - if N*BNUM_DIGIT_WIDTH+$bias+$mantissa_bits<=lsb_biased{ + if (N*BNUM_DIGIT_WIDTH) as isize<=lsb{ return Err(FixedFromFloatError::Overflow); } // underflow is ok, we only need to know the alignment - let lsb_alignment=lsb_biased.wrapping_sub($bias+$mantissa_bits)&((1<>DIGIT_SHIFT; let mut i_m; let mut i_d; - if lsb_biased<$bias+$mantissa_bits{ + if digit_index<0{ // lsb of mantissa is lower than lsb of fixed point // [0,0,0,0]<>DIGIT_SHIFT) as usize; + i_m=-digit_index as usize; i_d=0; }else{ - // f32 -> 19 bit too big - // f64 -> 48 bits too big // lsb of mantissa is higher than lsb of fixed point // [0,0,0,0]<>DIGIT_SHIFT; + i_d=digit_index as usize; } while i_m= bias, i_m is 0, we skip i_d bytes in digits - i_m = (((($bias + $mantissa_bits) - lsb_biased) >> DIGIT_SHIFT) & is_less); - i_d = ((lsb_biased.wrapping_sub($bias + $mantissa_bits) >> DIGIT_SHIFT) & !is_less); + i_m = (((($bias + $mantissa_bits) - lsb) >> DIGIT_SHIFT) & is_less); + i_d = ((lsb.wrapping_sub($bias + $mantissa_bits) >> DIGIT_SHIFT) & !is_less); // Calculate how many bytes to copy safely let m_bytes_len = m_bytes.len(); -- 2.49.1 From 83c7c2d3a84cc6b37532e326369fbb978fe3e1d0 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 10:33:22 -0700 Subject: [PATCH 83/86] bug is fixed --- lib/fixed_wide/src/tests.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index ab90410f..a9972753 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -116,11 +116,10 @@ fn from_f32(){ let b:Result=Into::::into(F64_32::MAX).try_into(); assert_eq!(b,Ok(a)); //I32F32::MIN hits a special case since it's not representable as a positive signed integer - //TODO: don't return an overflow because this is technically possible let a=F64_32::MIN; let f:f32=a.into(); let b:Result=f.try_into(); - assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Overflow)); + assert_eq!(b,Ok(a)); //16 is within the 24 bits of float precision let b:Result=Into::::into(-F64_32::MIN.widen_128()).try_into(); assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Overflow)); -- 2.49.1 From 1f20d7e6a0efb3a6e077d8c2885d1f5ed5454bc1 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 10:36:15 -0700 Subject: [PATCH 84/86] write test less goofy --- lib/fixed_wide/src/tests.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index a9972753..6b9d4b11 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -121,7 +121,9 @@ fn from_f32(){ let b:Result=f.try_into(); assert_eq!(b,Ok(a)); //16 is within the 24 bits of float precision - let b:Result=Into::::into(-F64_32::MIN.widen_128()).try_into(); + let a=-F64_32::MIN.widen_128(); + let f:f32=a.into(); + let b:Result=f.try_into(); assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Overflow)); let b:Result=f32::MIN_POSITIVE.try_into(); assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Underflow)); -- 2.49.1 From f44d6756b0431b0fbc641e7ffb66c65266bbf3c6 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Tue, 24 Mar 2026 10:46:21 -0700 Subject: [PATCH 85/86] use biased --- lib/fixed_wide/src/fixed.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/fixed_wide/src/fixed.rs b/lib/fixed_wide/src/fixed.rs index 04f79d1f..2d5e9fe1 100644 --- a/lib/fixed_wide/src/fixed.rs +++ b/lib/fixed_wide/src/fixed.rs @@ -333,13 +333,14 @@ macro_rules! impl_from_float{ =>{ let (m,e,s)=$decode(value); let mut digits=[0u8;N]; - let lsb=e as isize+F as isize+1-$bias-$mantissa_bits; - if lsb+$mantissa_bits<0{ + let msb_biased=e as usize+F+1; + if msb_biased<$bias{ return Err(FixedFromFloatError::Underflow); }; - if (N*BNUM_DIGIT_WIDTH) as isize<=lsb{ + if N*BNUM_DIGIT_WIDTH+$bias<=msb_biased{ return Err(FixedFromFloatError::Overflow); } + let lsb=msb_biased as isize-$bias-$mantissa_bits; // underflow is ok, we only need to know the alignment let lsb_alignment=lsb&((1< Date: Tue, 24 Mar 2026 10:49:40 -0700 Subject: [PATCH 86/86] Revert "bug is fixed" This reverts commit 83c7c2d3a84cc6b37532e326369fbb978fe3e1d0. --- lib/fixed_wide/src/tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/fixed_wide/src/tests.rs b/lib/fixed_wide/src/tests.rs index 6b9d4b11..c729f41c 100644 --- a/lib/fixed_wide/src/tests.rs +++ b/lib/fixed_wide/src/tests.rs @@ -116,10 +116,11 @@ fn from_f32(){ let b:Result=Into::::into(F64_32::MAX).try_into(); assert_eq!(b,Ok(a)); //I32F32::MIN hits a special case since it's not representable as a positive signed integer + //TODO: don't return an overflow because this is technically possible let a=F64_32::MIN; let f:f32=a.into(); let b:Result=f.try_into(); - assert_eq!(b,Ok(a)); + assert_eq!(b,Err(crate::fixed::FixedFromFloatError::Overflow)); //16 is within the 24 bits of float precision let a=-F64_32::MIN.widen_128(); let f:f32=a.into(); -- 2.49.1