named function
This commit is contained in:
parent
e0dba8840e
commit
502ab7f33f
@ -320,6 +320,11 @@ impl<const SRC:usize,const F:usize> Fixed<SRC,F>{
|
|||||||
|
|
||||||
macro_rules! impl_const{
|
macro_rules! impl_const{
|
||||||
($n:expr)=>{
|
($n:expr)=>{
|
||||||
|
impl Fixed<{$n*2},{$n*2*32}>{
|
||||||
|
pub fn halve_precision(self)->Fixed<$n,{$n*32}>{
|
||||||
|
Fixed::from_bits(bnum::cast::As::as_(self.bits.shr($n*32)))
|
||||||
|
}
|
||||||
|
}
|
||||||
impl Fixed<$n,{$n*32}>{
|
impl Fixed<$n,{$n*32}>{
|
||||||
paste::item!{
|
paste::item!{
|
||||||
pub fn sqrt_unchecked(self)->Self{
|
pub fn sqrt_unchecked(self)->Self{
|
||||||
|
@ -19,9 +19,7 @@ macro_rules! impl_zeroes{
|
|||||||
Ordering::Greater=>{
|
Ordering::Greater=>{
|
||||||
//start with f64 sqrt
|
//start with f64 sqrt
|
||||||
//failure case: 2^63 < sqrt(2^127)
|
//failure case: 2^63 < sqrt(2^127)
|
||||||
let planar_radicand_wide=radicand.sqrt();
|
let planar_radicand=radicand.sqrt().halve_precision();
|
||||||
//lazy hack
|
|
||||||
let planar_radicand=Self::from_bits(bnum::cast::As::as_(planar_radicand_wide.bits.shr($n*32)));
|
|
||||||
//TODO: one or two newtons
|
//TODO: one or two newtons
|
||||||
//sort roots ascending and avoid taking the difference of large numbers
|
//sort roots ascending and avoid taking the difference of large numbers
|
||||||
match (a2pos,Self::ZERO<a1){
|
match (a2pos,Self::ZERO<a1){
|
||||||
|
Loading…
Reference in New Issue
Block a user