malachite-float 0.9.1

The arbitrary-precision floating-point type Float, with efficient algorithms partially derived from MPFR.
Documentation
// Copyright © 2026 Mikhail Hogrefe
//
// This file is part of Malachite.
//
// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version
// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.

use crate::Float;
use crate::malachite_base::num::basic::integers::PrimitiveInt;
use malachite_base::rounding_modes::RoundingMode::{self, *};
use malachite_nz::platform::Limb;
use std::cmp::Ordering::{self, *};

pub fn sqrt_pi_prec_round_simple(prec: u64, rm: RoundingMode) -> (Float, Ordering) {
    let mut working_prec = prec + 10;
    let mut increment = Limb::WIDTH;
    loop {
        let pi_lo = Float::pi_prec_round(working_prec, Floor).0;
        let mut pi_hi = pi_lo.clone();
        pi_hi.increment();
        let lo = pi_lo.sqrt_round(Floor).0;
        let hi = pi_hi.sqrt_round(Ceiling).0;
        let (sqrt_pi_lo, mut o_lo) = Float::from_float_prec_round(lo, prec, rm);
        let (sqrt_pi_hi, mut o_hi) = Float::from_float_prec_round(hi, prec, rm);
        if o_lo == Equal {
            o_lo = o_hi;
        }
        if o_hi == Equal {
            o_hi = o_lo;
        }
        if o_lo == o_hi && sqrt_pi_lo == sqrt_pi_hi {
            return (sqrt_pi_lo, o_lo);
        }
        working_prec += increment;
        increment = working_prec >> 1;
    }
}