FIX: Consolidate two structs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
calc_result::{CalcResult, CellReference},
|
||||
expressions::{parser::Node, token::Error},
|
||||
calc_result::CalcResult,
|
||||
expressions::{parser::Node, token::Error, types::CellReferenceIndex},
|
||||
model::Model,
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ use super::transcendental::{bessel_i, bessel_j, bessel_k, bessel_y, erf};
|
||||
// EXCEL_BESSEL(x, n) => bessel(n, x)
|
||||
|
||||
impl Model {
|
||||
pub(crate) fn fn_besseli(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_besseli(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ impl Model {
|
||||
}
|
||||
CalcResult::Number(result)
|
||||
}
|
||||
pub(crate) fn fn_besselj(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_besselj(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ impl Model {
|
||||
CalcResult::Number(result)
|
||||
}
|
||||
|
||||
pub(crate) fn fn_besselk(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_besselk(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ impl Model {
|
||||
CalcResult::Number(result)
|
||||
}
|
||||
|
||||
pub(crate) fn fn_bessely(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_bessely(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ impl Model {
|
||||
CalcResult::Number(result)
|
||||
}
|
||||
|
||||
pub(crate) fn fn_erf(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_erf(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -141,7 +141,7 @@ impl Model {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn fn_erfprecise(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_erfprecise(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
};
|
||||
@@ -152,7 +152,7 @@ impl Model {
|
||||
CalcResult::Number(erf(x))
|
||||
}
|
||||
|
||||
pub(crate) fn fn_erfc(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_erfc(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
};
|
||||
@@ -163,7 +163,7 @@ impl Model {
|
||||
CalcResult::Number(1.0 - erf(x))
|
||||
}
|
||||
|
||||
pub(crate) fn fn_erfcprecise(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_erfcprecise(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::{
|
||||
calc_result::{CalcResult, CellReference},
|
||||
expressions::parser::Node,
|
||||
expressions::token::Error,
|
||||
calc_result::CalcResult,
|
||||
expressions::{parser::Node, token::Error, types::CellReferenceIndex},
|
||||
model::Model,
|
||||
};
|
||||
|
||||
@@ -10,7 +9,7 @@ const MAX: f64 = 281474976710655.0;
|
||||
|
||||
impl Model {
|
||||
// BITAND( number1, number2)
|
||||
pub(crate) fn fn_bitand(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_bitand(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -48,7 +47,7 @@ impl Model {
|
||||
}
|
||||
|
||||
// BITOR(number1, number2)
|
||||
pub(crate) fn fn_bitor(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_bitor(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -86,7 +85,7 @@ impl Model {
|
||||
}
|
||||
|
||||
// BITXOR(number1, number2)
|
||||
pub(crate) fn fn_bitxor(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_bitxor(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -124,7 +123,7 @@ impl Model {
|
||||
}
|
||||
|
||||
// BITLSHIFT(number, shift_amount)
|
||||
pub(crate) fn fn_bitlshift(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_bitlshift(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -178,7 +177,7 @@ impl Model {
|
||||
}
|
||||
|
||||
// BITRSHIFT(number, shift_amount)
|
||||
pub(crate) fn fn_bitrshift(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_bitrshift(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use std::fmt;
|
||||
|
||||
use crate::{
|
||||
calc_result::{CalcResult, CellReference},
|
||||
calc_result::CalcResult,
|
||||
expressions::{
|
||||
lexer::util::get_tokens,
|
||||
parser::Node,
|
||||
token::{Error, OpSum, TokenType},
|
||||
types::CellReferenceIndex,
|
||||
},
|
||||
model::Model,
|
||||
number_format::to_precision,
|
||||
@@ -185,7 +186,7 @@ impl Model {
|
||||
fn get_complex_number(
|
||||
&mut self,
|
||||
node: &Node,
|
||||
cell: CellReference,
|
||||
cell: CellReferenceIndex,
|
||||
) -> Result<(f64, f64, Suffix), CalcResult> {
|
||||
let value = match self.get_string(node, cell) {
|
||||
Ok(s) => s,
|
||||
@@ -200,7 +201,7 @@ impl Model {
|
||||
}
|
||||
}
|
||||
// COMPLEX(real_num, i_num, [suffix])
|
||||
pub(crate) fn fn_complex(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_complex(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(2..=3).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -237,7 +238,7 @@ impl Model {
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn fn_imabs(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imabs(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -248,7 +249,7 @@ impl Model {
|
||||
CalcResult::Number(f64::sqrt(x * x + y * y))
|
||||
}
|
||||
|
||||
pub(crate) fn fn_imaginary(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imaginary(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -258,7 +259,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::Number(y)
|
||||
}
|
||||
pub(crate) fn fn_imargument(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imargument(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -272,7 +273,7 @@ impl Model {
|
||||
let angle = f64::atan2(y, x);
|
||||
CalcResult::Number(angle)
|
||||
}
|
||||
pub(crate) fn fn_imconjugate(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imconjugate(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -283,7 +284,7 @@ impl Model {
|
||||
let complex = Complex { x, y: -y, suffix };
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imcos(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imcos(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -303,7 +304,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imcosh(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imcosh(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -323,7 +324,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imcot(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imcot(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -367,7 +368,7 @@ impl Model {
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn fn_imcsc(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imcsc(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -395,7 +396,7 @@ impl Model {
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn fn_imcsch(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imcsch(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -423,7 +424,7 @@ impl Model {
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn fn_imdiv(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imdiv(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -450,7 +451,7 @@ impl Model {
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn fn_imexp(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imexp(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -466,7 +467,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imln(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imln(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -485,7 +486,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imlog10(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imlog10(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -504,7 +505,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imlog2(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imlog2(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -527,7 +528,7 @@ impl Model {
|
||||
// IMPOWER(imnumber, power)
|
||||
// If $(r, \theta)$ is the polar representation the formula is:
|
||||
// $$ x = r^n*\cos(n\dot\theta), y = r^n*\csin(n\dot\theta) $
|
||||
pub(crate) fn fn_impower(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_impower(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -570,7 +571,7 @@ impl Model {
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn fn_improduct(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_improduct(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -595,7 +596,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imreal(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imreal(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -605,7 +606,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::Number(x)
|
||||
}
|
||||
pub(crate) fn fn_imsec(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imsec(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -628,7 +629,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imsech(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imsech(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -651,7 +652,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imsin(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imsin(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -667,7 +668,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imsinh(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imsinh(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -683,7 +684,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imsqrt(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imsqrt(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -702,7 +703,7 @@ impl Model {
|
||||
};
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
pub(crate) fn fn_imsub(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imsub(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -725,7 +726,7 @@ impl Model {
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn fn_imsum(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imsum(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 2 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -748,7 +749,7 @@ impl Model {
|
||||
CalcResult::String(complex.to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn fn_imtan(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_imtan(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
calc_result::{CalcResult, CellReference},
|
||||
expressions::parser::Node,
|
||||
expressions::token::Error,
|
||||
calc_result::CalcResult,
|
||||
expressions::{parser::Node, token::Error, types::CellReferenceIndex},
|
||||
model::Model,
|
||||
};
|
||||
|
||||
@@ -44,7 +43,7 @@ fn convert_temperature(
|
||||
|
||||
impl Model {
|
||||
// CONVERT(number, from_unit, to_unit)
|
||||
pub(crate) fn fn_convert(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_convert(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 3 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use crate::{
|
||||
calc_result::{CalcResult, CellReference},
|
||||
expressions::parser::Node,
|
||||
calc_result::CalcResult,
|
||||
expressions::{parser::Node, types::CellReferenceIndex},
|
||||
model::Model,
|
||||
number_format::to_precision,
|
||||
};
|
||||
|
||||
impl Model {
|
||||
// DELTA(number1, [number2])
|
||||
pub(crate) fn fn_delta(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_delta(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
let arg_count = args.len();
|
||||
if !(1..=2).contains(&arg_count) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
@@ -33,7 +33,7 @@ impl Model {
|
||||
}
|
||||
|
||||
// GESTEP(number, [step])
|
||||
pub(crate) fn fn_gestep(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_gestep(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
let arg_count = args.len();
|
||||
if !(1..=2).contains(&arg_count) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::{
|
||||
calc_result::{CalcResult, CellReference},
|
||||
expressions::parser::Node,
|
||||
expressions::token::Error,
|
||||
calc_result::CalcResult,
|
||||
expressions::{parser::Node, token::Error, types::CellReferenceIndex},
|
||||
model::Model,
|
||||
};
|
||||
|
||||
@@ -34,7 +33,7 @@ fn from_binary_to_decimal(value: f64) -> Result<i64, String> {
|
||||
|
||||
impl Model {
|
||||
// BIN2DEC(number)
|
||||
pub(crate) fn fn_bin2dec(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_bin2dec(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() != 1 {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -49,7 +48,7 @@ impl Model {
|
||||
}
|
||||
|
||||
// BIN2HEX(number, [places])
|
||||
pub(crate) fn fn_bin2hex(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_bin2hex(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -93,7 +92,7 @@ impl Model {
|
||||
}
|
||||
|
||||
// BIN2OCT(number, [places])
|
||||
pub(crate) fn fn_bin2oct(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_bin2oct(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -136,7 +135,7 @@ impl Model {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn fn_dec2bin(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_dec2bin(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -175,7 +174,7 @@ impl Model {
|
||||
CalcResult::String(result)
|
||||
}
|
||||
|
||||
pub(crate) fn fn_dec2hex(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_dec2hex(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -214,7 +213,7 @@ impl Model {
|
||||
CalcResult::String(result)
|
||||
}
|
||||
|
||||
pub(crate) fn fn_dec2oct(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_dec2oct(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -255,7 +254,7 @@ impl Model {
|
||||
}
|
||||
|
||||
// HEX2BIN(number, [places])
|
||||
pub(crate) fn fn_hex2bin(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_hex2bin(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -314,7 +313,7 @@ impl Model {
|
||||
}
|
||||
|
||||
// HEX2DEC(number)
|
||||
pub(crate) fn fn_hex2dec(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_hex2dec(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -345,7 +344,7 @@ impl Model {
|
||||
CalcResult::Number(value as f64)
|
||||
}
|
||||
|
||||
pub(crate) fn fn_hex2oct(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_hex2oct(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -403,7 +402,7 @@ impl Model {
|
||||
CalcResult::String(result)
|
||||
}
|
||||
|
||||
pub(crate) fn fn_oct2bin(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_oct2bin(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -458,7 +457,7 @@ impl Model {
|
||||
CalcResult::String(result)
|
||||
}
|
||||
|
||||
pub(crate) fn fn_oct2dec(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_oct2dec(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
@@ -486,7 +485,7 @@ impl Model {
|
||||
CalcResult::Number(value as f64)
|
||||
}
|
||||
|
||||
pub(crate) fn fn_oct2hex(&mut self, args: &[Node], cell: CellReference) -> CalcResult {
|
||||
pub(crate) fn fn_oct2hex(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if !(1..=2).contains(&args.len()) {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user