malachite-float 0.13.0

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 malachite_base::num::conversion::traits::IsReal;
use malachite_float::test_util::common::parse_hex_string;
use malachite_float::test_util::generators::float_gen;

#[test]
fn test_is_real() {
    let test = |s, s_hex, out| {
        let x = parse_hex_string(s_hex);
        assert_eq!(x.to_string(), s);

        assert_eq!(x.is_real(), out);
    };
    test("NaN", "NaN", false);
    test("Infinity", "Infinity", false);
    test("-Infinity", "-Infinity", false);
    test("0.0", "0x0.0", true);
    test("-0.0", "-0x0.0", true);

    test("1.0", "0x1.0#1", true);
    test("0.50", "0x0.8#1", true);
    test("123.0", "0x7b.0#7", true);
    test("3.1415926535897931", "0x3.243f6a8885a3#50", true);

    test("-1.0", "-0x1.0#1", true);
    test("-0.50", "-0x0.8#1", true);
    test("-123.0", "-0x7b.0#7", true);
    test("-3.1415926535897931", "-0x3.243f6a8885a3#50", true);
}

#[test]
fn is_real_properties() {
    float_gen().test_properties(|x| {
        assert_eq!(x.is_real(), x.is_finite());
        assert_eq!(x.is_real(), (-&x).is_real());
    });
}