#![cfg(any(feature = "d307", feature = "wide", feature = "x-wide"))]
use crate::types::widths::wide_trig_d307 as core;
use crate::support::rounding::RoundingMode;
use crate::wide_int::Int1024;
const GUARD_NARROW: u32 = crate::algos::exp::lookup_d307_s140_160_tang::GUARD_FOR_HYPER;
#[inline]
fn ex_enx(v: core::W, w: u32) -> (core::W, core::W) {
let ex = crate::algos::exp::lookup_d307_s140_160_tang::tang_exp_fixed(v, w);
let one_w = core::one(w);
let enx = core::div(one_w, ex, w);
(ex, enx)
}
#[inline]
#[must_use]
pub(crate) fn sinh_strict<const SCALE: u32>(raw: Int1024, mode: RoundingMode) -> Int1024 {
let w = SCALE + GUARD_NARROW;
let v = core::to_work_w(raw, GUARD_NARROW);
let (ex, enx) = ex_enx(v, w);
let two = core::lit(2);
let r = (ex - enx) / two;
core::round_to_storage_with(r, w, SCALE, mode)
}
#[inline]
#[must_use]
pub(crate) fn cosh_strict<const SCALE: u32>(raw: Int1024, mode: RoundingMode) -> Int1024 {
let w = SCALE + GUARD_NARROW;
let v = core::to_work_w(raw, GUARD_NARROW);
let (ex, enx) = ex_enx(v, w);
let two = core::lit(2);
let r = (ex + enx) / two;
core::round_to_storage_with(r, w, SCALE, mode)
}
#[inline]
#[must_use]
pub(crate) fn tanh_strict<const SCALE: u32>(raw: Int1024, mode: RoundingMode) -> Int1024 {
let w = SCALE + GUARD_NARROW;
let v = core::to_work_w(raw, GUARD_NARROW);
let (ex, enx) = ex_enx(v, w);
let r = core::div(ex - enx, ex + enx, w);
core::round_to_storage_with(r, w, SCALE, mode)
}