// Copyright (C) 2026 Kiyotsugu Arai
// SPDX-License-Identifier: LGPL-3.0-or-later

// Fixed_traits.hpp — numeric_traits<Fixed<...>> 特殊化
// Fixed.hpp と traits.hpp の循環参照を避けるため別ヘッダに分離

#ifndef CALX_CORE_FIXED_TRAITS_HPP
#define CALX_CORE_FIXED_TRAITS_HPP

#include <math/core/Fixed.hpp>
#include <math/core/traits.hpp>

namespace calx {

template<typename Rep, int Frac, typename RP, typename OP>
struct numeric_traits<Fixed<Rep, Frac, RP, OP>> {
    using F = Fixed<Rep, Frac, RP, OP>;
    using value_type = F;
    using category = floating_point_tag;

    static constexpr bool is_supported = true;
    static constexpr bool is_complex = false;
    static constexpr bool is_integer = false;
    static constexpr bool is_floating_point = false;

    static constexpr F zero() { return F(0); }
    static constexpr F one() { return F(1); }
    static constexpr F epsilon() { return F::epsilon(); }

    static constexpr F abs(F value) { return value.abs(); }
    static constexpr F conj(F value) { return value; }
    static constexpr F norm(F value) { return value * value; }
    static bool pivotBetter(F a, F b) { return abs(a) > abs(b); }

    static NumericState getState(F) { return NumericState::Normal; }
    static NumericError getError(F) { return NumericError::None; }
};

} // namespace calx

#endif // CALX_CORE_FIXED_TRAITS_HPP
