mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
ParserFunctions: Round numbers to default precision of 14 [#683]
This commit is contained in:
parent
c47820b1a9
commit
bc30fd8526
@ -80,6 +80,9 @@ public class Decimal_adp implements CompareAble {
|
|||||||
}
|
}
|
||||||
return new Decimal_adp(new_val);
|
return new Decimal_adp(new_val);
|
||||||
}
|
}
|
||||||
|
public Decimal_adp Round_to_default_precision() {
|
||||||
|
return new Decimal_adp(under.round(Decimal_adp_.Gplx_rounding_context));
|
||||||
|
}
|
||||||
public boolean Comp_gte(Decimal_adp v) {return under.doubleValue() >= v.under.doubleValue();}
|
public boolean Comp_gte(Decimal_adp v) {return under.doubleValue() >= v.under.doubleValue();}
|
||||||
public boolean Comp_gte(int v) {return under.doubleValue() >= v;}
|
public boolean Comp_gte(int v) {return under.doubleValue() >= v;}
|
||||||
public boolean Comp_lte(Decimal_adp v) {return under.doubleValue() <= v.under.doubleValue();}
|
public boolean Comp_lte(Decimal_adp v) {return under.doubleValue() <= v.under.doubleValue();}
|
||||||
|
@ -23,7 +23,9 @@ class Func_tkn_ln extends Func_tkn_base {
|
|||||||
@Override public boolean Calc_hook(Xop_ctx ctx, Pfunc_expr_shunter shunter, Val_stack val_stack) {
|
@Override public boolean Calc_hook(Xop_ctx ctx, Pfunc_expr_shunter shunter, Val_stack val_stack) {
|
||||||
Decimal_adp val = val_stack.Pop();
|
Decimal_adp val = val_stack.Pop();
|
||||||
if (val.Comp_lte(0)) {shunter.Err_set(ctx, Xol_msg_itm_.Id_pfunc_expr_invalid_argument_ln); return false;}
|
if (val.Comp_lte(0)) {shunter.Err_set(ctx, Xol_msg_itm_.Id_pfunc_expr_invalid_argument_ln); return false;}
|
||||||
val_stack.Push(Decimal_adp_.double_(Math_.Log(val.To_double())));
|
val = Decimal_adp_.double_(Math_.Log(val.To_double()));
|
||||||
|
val = val.Round_to_default_precision();// NOTE: needed for test; may need to apply to other ops; DATE:2020-03-24
|
||||||
|
val_stack.Push(val);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ public class Pfunc_expr_shunter {
|
|||||||
}
|
}
|
||||||
if (num == null) return Null_rslt;
|
if (num == null) return Null_rslt;
|
||||||
}
|
}
|
||||||
|
num = num.Round_to_default_precision(); // PURPOSE: number should be set to precision of 14; PAGE:de.wikipedia.org/wiki/Nationalpark_Mu_Ko_Ang_Thong ISSUE#:683 DATE:2020-03-24
|
||||||
val_stack.Push(num);
|
val_stack.Push(num);
|
||||||
mode_expr = false;
|
mode_expr = false;
|
||||||
break;
|
break;
|
||||||
|
@ -112,4 +112,7 @@ public class Pfunc_expr_tst {
|
|||||||
@Test public void Exc_unrecognized_word_ornot() {fxt.Test_parse_tmpl_str_test("{{#expr:0ornot0}}" , "{{test}}" , "<strong class=\"error\">Expression error: Unrecognised word \"ornot\"</strong>");} // PURPOSE: handle nan; EX: w:Help:Calculation
|
@Test public void Exc_unrecognized_word_ornot() {fxt.Test_parse_tmpl_str_test("{{#expr:0ornot0}}" , "{{test}}" , "<strong class=\"error\">Expression error: Unrecognised word \"ornot\"</strong>");} // PURPOSE: handle nan; EX: w:Help:Calculation
|
||||||
@Test public void Exc_unrecognized_word_notnot() {fxt.Test_parse_tmpl_str_test("{{#expr:notnot0}}" , "{{test}}" , "<strong class=\"error\">Expression error: Unrecognised word \"notnot\"</strong>");} // PURPOSE: handle nan; EX: w:Help:Calculation
|
@Test public void Exc_unrecognized_word_notnot() {fxt.Test_parse_tmpl_str_test("{{#expr:notnot0}}" , "{{test}}" , "<strong class=\"error\">Expression error: Unrecognised word \"notnot\"</strong>");} // PURPOSE: handle nan; EX: w:Help:Calculation
|
||||||
@Test public void Exc_unrecognized_word_sinln() {fxt.Test_parse_tmpl_str_test("{{#expr:sinln1.1}}" , "{{test}}" , "<strong class=\"error\">Expression error: Unrecognised word \"sinln\"</strong>");} // PURPOSE: handle nan; EX: w:Help:Calculation
|
@Test public void Exc_unrecognized_word_sinln() {fxt.Test_parse_tmpl_str_test("{{#expr:sinln1.1}}" , "{{test}}" , "<strong class=\"error\">Expression error: Unrecognised word \"sinln\"</strong>");} // PURPOSE: handle nan; EX: w:Help:Calculation
|
||||||
|
@Test public void Num_precision() {// PURPOSE: number should be set to precision of 14; PAGE:de.wikipedia.org/wiki/Nationalpark_Mu_Ko_Ang_Thong ISSUE#:683 DATE:2020-03-24
|
||||||
|
fxt.Test__parse__tmpl_to_html("{{#expr:15.064329981401556}}", "15.064329981402"); // fails if 15.06432998140155
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user