FIX: Value of SEC at 0 was incorrect

Also fixed imported errors of trigonometrical functions

Fixes #531
This commit is contained in:
Nicolás Hatcher
2025-11-11 22:06:56 +01:00
committed by Nicolás Hatcher Andrés
parent 3111a74530
commit 4b93174261
2 changed files with 20 additions and 23 deletions

View File

@@ -1250,11 +1250,8 @@ impl Model {
} else { } else {
Ok((f * PI).sqrt()) Ok((f * PI).sqrt())
}); });
single_number_fn!(fn_acot, |f| if f == 0.0 {
Err(Error::DIV) single_number_fn!(fn_acot, |f| Ok(f64::atan(1.0 / f)));
} else {
Ok(f64::atan(1.0 / f))
});
single_number_fn!(fn_acoth, |f: f64| if f.abs() == 1.0 { single_number_fn!(fn_acoth, |f: f64| if f.abs() == 1.0 {
Err(Error::DIV) Err(Error::DIV)
} else { } else {
@@ -1280,16 +1277,8 @@ impl Model {
} else { } else {
Ok(1.0 / f64::sinh(f)) Ok(1.0 / f64::sinh(f))
}); });
single_number_fn!(fn_sec, |f| if f == 0.0 { single_number_fn!(fn_sec, |f| Ok(1.0 / f64::cos(f)));
Err(Error::DIV) single_number_fn!(fn_sech, |f| Ok(1.0 / f64::cosh(f)));
} 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_exp, |f: f64| Ok(f64::exp(f))); single_number_fn!(fn_exp, |f: f64| Ok(f64::exp(f)));
single_number_fn!(fn_fact, |x: f64| { single_number_fn!(fn_fact, |x: f64| {
let x = x.floor(); let x = x.floor();

View File

@@ -624,6 +624,14 @@ impl Function {
Function::Arabic => "_xlfn.ARABIC".to_string(), Function::Arabic => "_xlfn.ARABIC".to_string(),
Function::Combina => "_xlfn.COMBINA".to_string(), Function::Combina => "_xlfn.COMBINA".to_string(),
Function::Sheets => "_xlfn.SHEETS".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(), _ => self.to_string(),
} }
@@ -659,14 +667,14 @@ impl Function {
"ASINH" => Some(Function::Asinh), "ASINH" => Some(Function::Asinh),
"ACOSH" => Some(Function::Acosh), "ACOSH" => Some(Function::Acosh),
"ATANH" => Some(Function::Atanh), "ATANH" => Some(Function::Atanh),
"ACOT" => Some(Function::Acot), "ACOT" | "_XLFN.ACOT" => Some(Function::Acot),
"COTH" => Some(Function::Coth), "COTH" | "_XLFN.COTH" => Some(Function::Coth),
"COT" => Some(Function::Cot), "COT" | "_XLFN.COT" => Some(Function::Cot),
"CSC" => Some(Function::Csc), "CSC" | "_XLFN.CSC" => Some(Function::Csc),
"CSCH" => Some(Function::Csch), "CSCH" | "_XLFN.CSCH" => Some(Function::Csch),
"SEC" => Some(Function::Sec), "SEC" | "_XLFN.SEC" => Some(Function::Sec),
"SECH" => Some(Function::Sech), "SECH" | "_XLFN.SECH" => Some(Function::Sech),
"ACOTH" => Some(Function::Acoth), "ACOTH" | "_XLFN.ACOTH" => Some(Function::Acoth),
"FACT" => Some(Function::Fact), "FACT" => Some(Function::Fact),
"FACTDOUBLE" => Some(Function::Factdouble), "FACTDOUBLE" => Some(Function::Factdouble),
"EXP" => Some(Function::Exp), "EXP" => Some(Function::Exp),