From 4b93174261f68db0f00b37a72b69f41d52464201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Hatcher?= Date: Tue, 11 Nov 2025 22:06:56 +0100 Subject: [PATCH] FIX: Value of SEC at 0 was incorrect Also fixed imported errors of trigonometrical functions Fixes #531 --- base/src/functions/mathematical.rs | 19 ++++--------------- base/src/functions/mod.rs | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/base/src/functions/mathematical.rs b/base/src/functions/mathematical.rs index d78b699..a03dc0b 100644 --- a/base/src/functions/mathematical.rs +++ b/base/src/functions/mathematical.rs @@ -1250,11 +1250,8 @@ impl Model { } else { Ok((f * PI).sqrt()) }); - single_number_fn!(fn_acot, |f| if f == 0.0 { - Err(Error::DIV) - } else { - Ok(f64::atan(1.0 / f)) - }); + + single_number_fn!(fn_acot, |f| Ok(f64::atan(1.0 / f))); single_number_fn!(fn_acoth, |f: f64| if f.abs() == 1.0 { Err(Error::DIV) } else { @@ -1280,16 +1277,8 @@ impl Model { } else { Ok(1.0 / f64::sinh(f)) }); - single_number_fn!(fn_sec, |f| if f == 0.0 { - Err(Error::DIV) - } else { - Ok(1.0 / f64::cos(f)) - }); - single_number_fn!(fn_sech, |f| if f == 0.0 { - Err(Error::DIV) - } else { - Ok(1.0 / f64::cosh(f)) - }); + single_number_fn!(fn_sec, |f| Ok(1.0 / f64::cos(f))); + single_number_fn!(fn_sech, |f| Ok(1.0 / f64::cosh(f))); single_number_fn!(fn_exp, |f: f64| Ok(f64::exp(f))); single_number_fn!(fn_fact, |x: f64| { let x = x.floor(); diff --git a/base/src/functions/mod.rs b/base/src/functions/mod.rs index 53a2868..a62fe45 100644 --- a/base/src/functions/mod.rs +++ b/base/src/functions/mod.rs @@ -624,6 +624,14 @@ impl Function { Function::Arabic => "_xlfn.ARABIC".to_string(), Function::Combina => "_xlfn.COMBINA".to_string(), Function::Sheets => "_xlfn.SHEETS".to_string(), + Function::Acoth => "_xlfn.ACOTH".to_string(), + Function::Cot => "_xlfn.COT".to_string(), + Function::Coth => "_xlfn.COTH".to_string(), + Function::Csc => "_xlfn.CSC".to_string(), + Function::Csch => "_xlfn.CSCH".to_string(), + Function::Sec => "_xlfn.SEC".to_string(), + Function::Sech => "_xlfn.SECH".to_string(), + Function::Acot => "_xlfn.ACOT".to_string(), _ => self.to_string(), } @@ -659,14 +667,14 @@ impl Function { "ASINH" => Some(Function::Asinh), "ACOSH" => Some(Function::Acosh), "ATANH" => Some(Function::Atanh), - "ACOT" => Some(Function::Acot), - "COTH" => Some(Function::Coth), - "COT" => Some(Function::Cot), - "CSC" => Some(Function::Csc), - "CSCH" => Some(Function::Csch), - "SEC" => Some(Function::Sec), - "SECH" => Some(Function::Sech), - "ACOTH" => Some(Function::Acoth), + "ACOT" | "_XLFN.ACOT" => Some(Function::Acot), + "COTH" | "_XLFN.COTH" => Some(Function::Coth), + "COT" | "_XLFN.COT" => Some(Function::Cot), + "CSC" | "_XLFN.CSC" => Some(Function::Csc), + "CSCH" | "_XLFN.CSCH" => Some(Function::Csch), + "SEC" | "_XLFN.SEC" => Some(Function::Sec), + "SECH" | "_XLFN.SECH" => Some(Function::Sech), + "ACOTH" | "_XLFN.ACOTH" => Some(Function::Acoth), "FACT" => Some(Function::Fact), "FACTDOUBLE" => Some(Function::Factdouble), "EXP" => Some(Function::Exp),