diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3fp.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/l3fp.sty | 909 |
1 files changed, 492 insertions, 417 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty b/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty index 3918bd5a161..cd23b05bfc1 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty @@ -59,7 +59,7 @@ %% ----------------------------------------------------------------------- %% \RequirePackage{l3bootstrap} -\GetIdInfo$Id: l3fp.dtx 4089 2012-08-14 04:52:20Z bruno $ +\GetIdInfo$Id: l3fp.dtx 4151 2012-08-28 11:51:52Z bruno $ {L3 Floating points} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -218,11 +218,15 @@ \int_const:Nn \c__fp_middle_shift_int { 5 0000 * 9999 } \int_const:Nn \c__fp_trailing_shift_int { 5 0000 * 10000 } \cs_new:Npn \__fp_pack:NNNNNw #1 #2#3#4#5 #6; { + #1#2#3#4#5 ; {#6} } +\cs_new:Npn \__fp_pack:NNNNNwn #1 #2#3#4#5 #6; #7 + { + #1#2#3#4#5 ; {#7} {#6} } \int_const:Nn \c__fp_big_leading_shift_int { - 15 2374 } \int_const:Nn \c__fp_big_middle_shift_int { 15 2374 * 9999 } \int_const:Nn \c__fp_big_trailing_shift_int { 15 2374 * 10000 } \cs_new:Npn \__fp_pack_big:NNNNNNw #1#2 #3#4#5#6 #7; { + #1#2#3#4#5#6 ; {#7} } +\cs_new:Npn \__fp_pack_big:NNNNNNwn #1#2 #3#4#5#6 #7; #8 + { + #1#2#3#4#5#6 ; {#8} {#7} } \int_const:Nn \c__fp_Bigg_leading_shift_int { - 20 0000 } \int_const:Nn \c__fp_Bigg_middle_shift_int { 20 0000 * 9999 } \int_const:Nn \c__fp_Bigg_trailing_shift_int { 20 0000 * 10000 } @@ -417,7 +421,7 @@ { \cs_set:Npn \__fp_invalid_operation:nnw ##1##2##3; } { #1 - \__fp_error:nffn { invalid } {##2} { \__fp_to_tl:w ##3; } { } + \__fp_error:nnfn { invalid } {##2} { \__fp_to_tl:w ##3; } { } \fp_flag_on:n { invalid_operation } ##1 } @@ -431,11 +435,10 @@ \exp_after:wN \c_nan_fp } \exp_args:Nno \use:n - { \cs_set:Npn \__fp_array_invalid_operation_o:nw ##1##2@ } + { \cs_set:Npn \__fp_invalid_operation_tl_o:nf ##1##2 } { #1 - \__fp_error:nffn { invalid } - {##1} { \__fp_array_to_clist:w ##2 @ } { } + \__fp_error:nnfn { invalid } {##1} {##2} { } \fp_flag_on:n { invalid_operation } \exp_after:wN \c_nan_fp } @@ -452,7 +455,7 @@ { \cs_set:Npn \__fp_division_by_zero_o:Nnw ##1##2##3; } { #1 - \__fp_error:nffn { zero-div } {##2} { \__fp_to_tl:w ##3; } { } + \__fp_error:nnfn { zero-div } {##2} { \__fp_to_tl:w ##3; } { } \fp_flag_on:n { division_by_zero } \exp_after:wN ##1 } @@ -499,7 +502,7 @@ } \cs_new:Npn \__fp_invalid_operation:nnw #1#2#3; { } \cs_new:Npn \__fp_invalid_operation_o:Nww #1#2; #3; { } -\cs_new:Npn \__fp_array_invalid_operation_o:nw #1 #2 @ { } +\cs_new:Npn \__fp_invalid_operation_tl_o:nf #1 #2 { } \cs_new:Npn \__fp_division_by_zero_o:Nnw #1#2#3; { } \cs_new:Npn \__fp_division_by_zero_o:NNww #1#2#3; #4; { } \cs_new:Npn \__fp_overflow:w { } @@ -512,21 +515,7 @@ { \__fp_invalid_operation:nnw { \exp_after:wN \c_nan_fp } } \cs_new:Npn \__fp_error:nnnn #1 { \__msg_kernel_expandable_error:nnnnn { kernel } { fp - #1 } } -\cs_generate_variant:Nn \__fp_error:nnnn { nff } -\cs_new:Npn \__fp_array_to_clist:w #1 @ - { - \__fp_array_to_clist_i:wwww ; - #1 - \__fp_array_to_clist_ii:ww \s__fp ; @ - } -\cs_new:Npn \__fp_array_to_clist_i:wwww #1; #2 \s__fp #3; #4 @ - { - #2 - \exp_after:wN \__fp_array_to_clist_i:wwww - \tex_romannumeral:D -`0 \__fp_to_tl:w \s__fp #3 ; ; - #4 , ~ #1 @ - } -\cs_new:Npn \__fp_array_to_clist_ii:ww #1 ; , ~ , ~ #2 @ {#2} +\cs_generate_variant:Nn \__fp_error:nnnn { nnf, nff } \__msg_kernel_new:nnnn { kernel } { unknown-fpu-exception } { The~FPU~exception~'#1'~is~not~known:~that~trap~will~never~be~triggered. } { @@ -687,7 +676,10 @@ \cs_new:Npn \__fp_round:Nww #1#2 ; #3 ; { \__fp_small_int:wTF #3; { \__fp_round:Nwn #1#2; } - { \__fp_array_invalid_operation_o:nw { round } #2; #3; @ } + { + \__fp_invalid_operation_tl_o:nf + { round } { \__fp_array_to_clist:n { #2; #3; } } + } } \cs_new:Npn \__fp_round:Nwn #1 \s__fp \__fp_chk:w #2#3#4; #5 { @@ -808,7 +800,7 @@ \cs_new:Npn \__fp_type_from_scan:N #1 { \exp_after:wN \__fp_type_from_scan:w - \token_to_str:N #1 \q_mark S--FP \q_mark \q_stop + \token_to_str:N #1 \q_mark S--FP-? \q_mark \q_stop } \cs_new:Npn \__fp_type_from_scan:w #1 S--FP #2 \q_mark #3 \q_stop {#2} } @@ -877,39 +869,26 @@ } \cs_new:Npn \__fp_parse_operand_relax:NN #1#2 { - \__fp_parse_operand_relax_aux:wwnw - #2 \s__fp_mark - { - \__fp_exp_after_o:nw - { - \tex_romannumeral:D -`0 - \exp_after:wN \__fp_parse_infix:NN - \exp_after:wN #1 \tex_romannumeral:D \__fp_parse_expand:w - } - \s__fp - } - \s__fp #2 - { - \__msg_kernel_expandable_error:nn { kernel } { fp-early-end } - \exp_after:wN \c_nan_fp - \tex_romannumeral:D -`0 - \__fp_parse_infix:NN #1 - \s__fp_mark - } - \s__fp_mark - { - \__msg_kernel_expandable_error:nnn - { kernel } { bad-variable } {#2} - \exp_after:wN \c_nan_fp - \tex_romannumeral:D -`0 - \exp_after:wN \__fp_parse_infix:NN - \exp_after:wN #1 - \tex_romannumeral:D \__fp_parse_expand:w - } - \s__fp_mark \s__fp_stop + \cs:w __fp_exp_after \__fp_type_from_scan:N #2 _f:nw \cs_end: + { + \exp_after:wN \__fp_parse_infix:NN + \exp_after:wN #1 \tex_romannumeral:D \__fp_parse_expand:w + } + #2 + } +\cs_new:Npn \__fp_exp_after_mark_f:nw #1 + { + \__msg_kernel_expandable_error:nn { kernel } { fp-early-end } + \exp_after:wN \c_nan_fp + \tex_romannumeral:D -`0 #1 + } +\cs_new:cpn { __fp_exp_after_?_f:nw } #1#2 + { + \__msg_kernel_expandable_error:nnn + { kernel } { bad-variable } {#2} + \exp_after:wN \c_nan_fp + \tex_romannumeral:D -`0 #1 } -\cs_new:Npn \__fp_parse_operand_relax_aux:wwnw - #1 \s__fp #2 \s__fp_mark #3 #4 \s__fp_mark \s__fp_stop { #3 } \cs_new:Npn \__fp_parse_operand_other:NN #1 #2 { \if_int_compare:w @@ -1447,8 +1426,9 @@ \cs:w __fp \__fp_type_from_scan:N #2 + _ #4 \__fp_type_from_scan:N #5 - _ #4 _o:ww + _o:ww \cs_end: #2#3 #5#6 \tex_romannumeral:D -`0 #7 #1 @@ -1504,7 +1484,8 @@ \tex_romannumeral:D -`0 \__fp_parse_infix:NN } } -\tl_map_inline:nn { {abs} {cos} {cot} {exp} {ln} {sin} {tan} } +\tl_map_inline:nn + { {abs} {cos} {cot} {csc} {exp} {ln} {sec} {sin} {tan} } { \cs_new:cpn { __fp_parse_word_#1:N } ##1 { @@ -1600,7 +1581,7 @@ { \token_if_eq_meaning:NNTF #3 \__fp_parse_infix_):N { - \__fp_parse_exp_after_array:wf #2 \s__fp_stop + \__fp_exp_after_array_f:w #2 \s__fp_stop \exp_after:wN \__fp_parse_infix:NN \exp_after:wN #1 \tex_romannumeral:D \__fp_parse_expand:w @@ -1611,13 +1592,13 @@ } } \group_end: -\cs_new:Npn \__fp_parse_exp_after_array:wf #1 +\cs_new:Npn \__fp_exp_after_array_f:w #1 { - \cs:w __fp \__fp_type_from_scan:N #1 _exp_after_f:nw \cs_end: - { \__fp_parse_exp_after_array:wf } + \cs:w __fp_exp_after \__fp_type_from_scan:N #1 _f:nw \cs_end: + { \__fp_exp_after_array_f:w } #1 } -\cs_new:Npn \__fp_stop_exp_after_f:nw #1#2 { } +\cs_new:Npn \__fp_exp_after_stop_f:nw #1#2 { } \cs_new:cpn {__fp_parse_prefix_.:Nw} #1 { \exp_after:wN \__fp_parse_infix_after_operand:NwN @@ -1990,12 +1971,12 @@ \cs_new:Npn \__fp_compare_npos:nwnw #1#2; #3#4; { \if_int_compare:w #1 = #3 \exp_stop_f: - \__fp_compare_mantissa:nnnnnnnn #2 #4 + \__fp_compare_significand:nnnnnnnn #2 #4 \else: \if_int_compare:w #1 < #3 - \fi: 1 \fi: } -\cs_new:Npn \__fp_compare_mantissa:nnnnnnnn #1#2#3#4#5#6#7#8 +\cs_new:Npn \__fp_compare_significand:nnnnnnnn #1#2#3#4#5#6#7#8 { \if_int_compare:w #1#2 = #5#6 \exp_stop_f: \if_int_compare:w #3#4 = #7#8 \exp_stop_f: @@ -2007,6 +1988,62 @@ \if_int_compare:w #1#2 < #5#6 - \fi: 1 \fi: } +\cs_new:Npn \fp_do_until:nn #1#2 + { + #2 + \fp_compare:nF {#1} + { \fp_do_until:nn {#1} {#2} } + } +\cs_new:Npn \fp_do_while:nn #1#2 + { + #2 + \fp_compare:nT {#1} + { \fp_do_while:nn {#1} {#2} } + } +\cs_new:Npn \fp_until_do:nn #1#2 + { + \fp_compare:nF {#1} + { + #2 + \fp_until_do:nn {#1} {#2} + } + } +\cs_new:Npn \fp_while_do:nn #1#2 + { + \fp_compare:nT {#1} + { + #2 + \fp_while_do:nn {#1} {#2} + } + } +\cs_new:Npn \fp_do_until:nNnn #1#2#3#4 + { + #4 + \fp_compare:nNnF {#1} #2 {#3} + { \fp_do_until:nNnn {#1} #2 {#3} {#4} } + } +\cs_new:Npn \fp_do_while:nNnn #1#2#3#4 + { + #4 + \fp_compare:nNnT {#1} #2 {#3} + { \fp_do_while:nNnn {#1} #2 {#3} {#4} } + } +\cs_new:Npn \fp_until_do:nNnn #1#2#3#4 + { + \fp_compare:nNnF {#1} #2 {#3} + { + #4 + \fp_until_do:nNnn {#1} #2 {#3} {#4} + } + } +\cs_new:Npn \fp_while_do:nNnn #1#2#3#4 + { + \fp_compare:nNnT {#1} #2 {#3} + { + #4 + \fp_while_do:nNnn {#1} #2 {#3} {#4} + } + } \cs_new:Npn \__fp_max_o:w #1 @ { \exp_after:wN \__fp_minmax_loop:Nww @@ -2083,7 +2120,7 @@ \__fp_ternary_break_point:n { \exp_after:wN \__fp_ternary_i:NwwN } \exp_after:wN #1 \tex_romannumeral:D -`0 - \__fp_parse_exp_after_array:wf #3 \s__fp_stop + \__fp_exp_after_array_f:w #3 \s__fp_stop \exp_after:wN @ \tex_romannumeral:D \__fp_parse_until:Nw \c_two @@ -2094,7 +2131,7 @@ \exp_after:wN \__fp_parse_until_test:NwN \exp_after:wN #1 \tex_romannumeral:D -`0 - \__fp_parse_exp_after_array:wf #3 \s__fp_stop + \__fp_exp_after_array_f:w #3 \s__fp_stop \exp_after:wN #4 \exp_after:wN #1 \fi: @@ -2117,7 +2154,7 @@ \exp_after:wN \__fp_parse_until_test:NwN \exp_after:wN #1 \tex_romannumeral:D -`0 - \__fp_parse_exp_after_array:wf #2 \s__fp_stop + \__fp_exp_after_array_f:w #2 \s__fp_stop #4 #1 } \cs_new:Npn \__fp_ternary_ii:NwwN #1#2@#3@#4 @@ -2125,7 +2162,7 @@ \exp_after:wN \__fp_parse_until_test:NwN \exp_after:wN #1 \tex_romannumeral:D -`0 - \__fp_parse_exp_after_array:wf #3 \s__fp_stop + \__fp_exp_after_array_f:w #3 \s__fp_stop #4 #1 } %% File: l3fp-basics.dtx Copyright (C) 2011-2012 The LaTeX3 Project @@ -2273,7 +2310,7 @@ \cs_new:Npn \__fp_add_big_i_o:wNww #1; #2 #3; #4; { \__fp_decimate:nNnnnn {#1} - \__fp_add_mantissa_o:NnnwnnnnN + \__fp_add_significand_o:NnnwnnnnN #4 #3 #2 @@ -2281,34 +2318,34 @@ \cs_new:Npn \__fp_add_big_ii_o:wNww #1; #2 #3; #4; { \__fp_decimate:nNnnnn {#1} - \__fp_add_mantissa_o:NnnwnnnnN + \__fp_add_significand_o:NnnwnnnnN #3 #4 #2 } -\cs_new:Npn \__fp_add_mantissa_o:NnnwnnnnN #1 #2#3 #4; #5#6#7#8 +\cs_new:Npn \__fp_add_significand_o:NnnwnnnnN #1 #2#3 #4; #5#6#7#8 { - \exp_after:wN \__fp_add_mantissa_test_o:N + \exp_after:wN \__fp_add_significand_test_o:N \int_use:N \__int_eval:w 1#5#6 + #2 - \exp_after:wN \__fp_add_mantissa_pack:NNNNNNN + \exp_after:wN \__fp_add_significand_pack:NNNNNNN \int_use:N \__int_eval:w 1#7#8 + #3 ; #1 } -\cs_new:Npn \__fp_add_mantissa_pack:NNNNNNN #1 #2#3#4#5#6#7 +\cs_new:Npn \__fp_add_significand_pack:NNNNNNN #1 #2#3#4#5#6#7 { \if_meaning:w 2 #1 + \c_one \fi: ; #2 #3 #4 #5 #6 #7 ; } -\cs_new:Npn \__fp_add_mantissa_test_o:N #1 +\cs_new:Npn \__fp_add_significand_test_o:N #1 { \if_meaning:w 2 #1 - \exp_after:wN \__fp_add_mantissa_carry_o:wwwNN + \exp_after:wN \__fp_add_significand_carry_o:wwwNN \else: - \exp_after:wN \__fp_add_mantissa_no_carry_o:wwwNN + \exp_after:wN \__fp_add_significand_no_carry_o:wwwNN \fi: } -\cs_new:Npn \__fp_add_mantissa_no_carry_o:wwwNN +\cs_new:Npn \__fp_add_significand_no_carry_o:wwwNN #1; #2; #3#4 ; #5#6 { \exp_after:wN \__fp_basics_pack_high:NNNNNw @@ -2318,7 +2355,7 @@ + \__fp_round:NNN #6 #4 #5 \exp_after:wN ; } -\cs_new:Npn \__fp_add_mantissa_carry_o:wwwNN +\cs_new:Npn \__fp_add_significand_carry_o:wwwNN #1; #2; #3#4; #5#6 { + \c_one @@ -2527,41 +2564,41 @@ \exp_after:wN #1 \int_use:N \__int_eval:w #4 + #8 - \__fp_mul_mantissa_o:nnnnNnnnn #5 #1 #9 + \__fp_mul_significand_o:nnnnNnnnn #5 #1 #9 } -\cs_new:Npn \__fp_mul_mantissa_o:nnnnNnnnn #1#2#3#4 #5 #6#7#8#9 +\cs_new:Npn \__fp_mul_significand_o:nnnnNnnnn #1#2#3#4 #5 #6#7#8#9 { - \exp_after:wN \__fp_mul_mantissa_test_f:NNN + \exp_after:wN \__fp_mul_significand_test_f:NNN \exp_after:wN #5 \int_use:N \__int_eval:w 99990000 + #1*#6 + - \exp_after:wN \__fp_mul_mantissa_keep:NNNNNw + \exp_after:wN \__fp_mul_significand_keep:NNNNNw \int_use:N \__int_eval:w 99990000 + #1*#7 + #2*#6 + - \exp_after:wN \__fp_mul_mantissa_keep:NNNNNw + \exp_after:wN \__fp_mul_significand_keep:NNNNNw \int_use:N \__int_eval:w 99990000 + #1*#8 + #2*#7 + #3*#6 + - \exp_after:wN \__fp_mul_mantissa_drop:NNNNNw + \exp_after:wN \__fp_mul_significand_drop:NNNNNw \int_use:N \__int_eval:w 99990000 + #1*#9 + #2*#8 + #3*#7 + #4*#6 + - \exp_after:wN \__fp_mul_mantissa_drop:NNNNNw + \exp_after:wN \__fp_mul_significand_drop:NNNNNw \int_use:N \__int_eval:w 99990000 + #2*#9 + #3*#8 + #4*#7 + - \exp_after:wN \__fp_mul_mantissa_drop:NNNNNw + \exp_after:wN \__fp_mul_significand_drop:NNNNNw \int_use:N \__int_eval:w 99990000 + #3*#9 + #4*#8 + - \exp_after:wN \__fp_mul_mantissa_drop:NNNNNw + \exp_after:wN \__fp_mul_significand_drop:NNNNNw \int_use:N \__int_eval:w 100000000 + #4*#9 ; ; \exp_after:wN ; } -\cs_new:Npn \__fp_mul_mantissa_drop:NNNNNw #1#2#3#4#5 #6; +\cs_new:Npn \__fp_mul_significand_drop:NNNNNw #1#2#3#4#5 #6; { #1#2#3#4#5 ; + #6 } -\cs_new:Npn \__fp_mul_mantissa_keep:NNNNNw #1#2#3#4#5 #6; +\cs_new:Npn \__fp_mul_significand_keep:NNNNNw #1#2#3#4#5 #6; { #1#2#3#4#5 ; #6 ; } -\cs_new:Npn \__fp_mul_mantissa_test_f:NNN #1 #2 #3 +\cs_new:Npn \__fp_mul_significand_test_f:NNN #1 #2 #3 { \if_meaning:w 0 #3 - \exp_after:wN \__fp_mul_mantissa_small_f:NNwwwN + \exp_after:wN \__fp_mul_significand_small_f:NNwwwN \else: - \exp_after:wN \__fp_mul_mantissa_large_f:NwwNNNN + \exp_after:wN \__fp_mul_significand_large_f:NwwNNNN \fi: #1 #3 } -\cs_new:Npn \__fp_mul_mantissa_large_f:NwwNNNN #1 #2; #3; #4#5#6#7; + +\cs_new:Npn \__fp_mul_significand_large_f:NwwNNNN #1 #2; #3; #4#5#6#7; + { \exp_after:wN \__fp_basics_pack_high:NNNNNw \int_use:N \__int_eval:w 1#2 @@ -2572,7 +2609,7 @@ \exp_after:wN #7 \__int_value:w \__fp_round_digit:Nw } -\cs_new:Npn \__fp_mul_mantissa_small_f:NNwwwN #1 #2#3; #4#5; #6; + #7 +\cs_new:Npn \__fp_mul_significand_small_f:NNwwwN #1 #2#3; #4#5; #6; + #7 { - \c_one \exp_after:wN \__fp_basics_pack_high:NNNNNw @@ -2606,34 +2643,34 @@ \exp_after:wN #1 \int_use:N \__int_eval:w #3 - #6 - \exp_after:wN \__fp_div_mantissa_i_o:wnnw + \exp_after:wN \__fp_div_significand_i_o:wnnw \int_use:N \__int_eval:w #7 \use_i:nnnn #8 + \c_one ; #4 {#7}{#8}#9 ; #1 } -\cs_new:Npn \__fp_div_mantissa_i_o:wnnw #1 ; #2#3 #4 ; +\cs_new:Npn \__fp_div_significand_i_o:wnnw #1 ; #2#3 #4 ; { - \exp_after:wN \__fp_div_mantissa_test_o:w + \exp_after:wN \__fp_div_significand_test_o:w \int_use:N \__int_eval:w - \exp_after:wN \__fp_div_mantissa_calc:wwnnnnnnn + \exp_after:wN \__fp_div_significand_calc:wwnnnnnnn \int_use:N \__int_eval:w 999999 + #2 #3 0 / #1 ; #2 #3 ; #4 - { \exp_after:wN \__fp_div_mantissa_ii:wwn \__int_value:w #1 } - { \exp_after:wN \__fp_div_mantissa_ii:wwn \__int_value:w #1 } - { \exp_after:wN \__fp_div_mantissa_ii:wwn \__int_value:w #1 } - { \exp_after:wN \__fp_div_mantissa_iii:wwnnnnn \__int_value:w #1 } + { \exp_after:wN \__fp_div_significand_ii:wwn \__int_value:w #1 } + { \exp_after:wN \__fp_div_significand_ii:wwn \__int_value:w #1 } + { \exp_after:wN \__fp_div_significand_ii:wwn \__int_value:w #1 } + { \exp_after:wN \__fp_div_significand_iii:wwnnnnn \__int_value:w #1 } } -\cs_new:Npn \__fp_div_mantissa_calc:wwnnnnnnn 1#1 +\cs_new:Npn \__fp_div_significand_calc:wwnnnnnnn 1#1 { \if_meaning:w 1 #1 - \exp_after:wN \__fp_div_mantissa_calc_i:wwnnnnnnn + \exp_after:wN \__fp_div_significand_calc_i:wwnnnnnnn \else: - \exp_after:wN \__fp_div_mantissa_calc_ii:wwnnnnnnn + \exp_after:wN \__fp_div_significand_calc_ii:wwnnnnnnn \fi: } -\cs_new:Npn \__fp_div_mantissa_calc_i:wwnnnnnnn #1; #2;#3#4 #5#6#7#8 #9 +\cs_new:Npn \__fp_div_significand_calc_i:wwnnnnnnn #1; #2;#3#4 #5#6#7#8 #9 { 1 1 #1 #9 \exp_after:wN ; @@ -2650,7 +2687,7 @@ - #1 * #8 ; {#5}{#6}{#7}{#8} } -\cs_new:Npn \__fp_div_mantissa_calc_ii:wwnnnnnnn #1; #2;#3#4 #5#6#7#8 #9 +\cs_new:Npn \__fp_div_significand_calc_ii:wwnnnnnnn #1; #2;#3#4 #5#6#7#8 #9 { 1 0 #1 #9 \exp_after:wN ; @@ -2667,33 +2704,33 @@ - #1 * #8 ; {#5}{#6}{#7}{#8} } -\cs_new:Npn \__fp_div_mantissa_ii:wwn #1; #2;#3 +\cs_new:Npn \__fp_div_significand_ii:wwn #1; #2;#3 { - \exp_after:wN \__fp_div_mantissa_pack:NNN + \exp_after:wN \__fp_div_significand_pack:NNN \int_use:N \__int_eval:w - \exp_after:wN \__fp_div_mantissa_calc:wwnnnnnnn + \exp_after:wN \__fp_div_significand_calc:wwnnnnnnn \int_use:N \__int_eval:w 999999 + #2 #3 0 / #1 ; #2 #3 ; } -\cs_new:Npn \__fp_div_mantissa_iii:wwnnnnn #1; #2;#3#4#5 #6#7 +\cs_new:Npn \__fp_div_significand_iii:wwnnnnn #1; #2;#3#4#5 #6#7 { 0 - \exp_after:wN \__fp_div_mantissa_iv:wwnnnnnnn + \exp_after:wN \__fp_div_significand_iv:wwnnnnnnn \int_use:N \__int_eval:w (\c_two * #2 #3) / #6 #7 ; % <- P #2 ; {#3} {#4} {#5} {#6} {#7} } -\cs_new:Npn \__fp_div_mantissa_iv:wwnnnnnnn #1; #2;#3#4#5 #6#7#8#9 +\cs_new:Npn \__fp_div_significand_iv:wwnnnnnnn #1; #2;#3#4#5 #6#7#8#9 { + \c_five * #1 - \exp_after:wN \__fp_div_mantissa_vi:Nw + \exp_after:wN \__fp_div_significand_vi:Nw \int_use:N \__int_eval:w -20 + 2*#2#3 - #1*#6#7 + - \exp_after:wN \__fp_div_mantissa_v:NN + \exp_after:wN \__fp_div_significand_v:NN \int_use:N \__int_eval:w 199980 + 2*#4 - #1*#8 + - \exp_after:wN \__fp_div_mantissa_v:NN + \exp_after:wN \__fp_div_significand_v:NN \int_use:N \__int_eval:w 200000 + 2*#5 - #1*#9 ; } -\cs_new:Npn \__fp_div_mantissa_v:NN #1#2 { #1#2 \__int_eval_end: + } -\cs_new:Npn \__fp_div_mantissa_vi:Nw #1#2; +\cs_new:Npn \__fp_div_significand_v:NN #1#2 { #1#2 \__int_eval_end: + } +\cs_new:Npn \__fp_div_significand_vi:Nw #1#2; { \if_meaning:w 0 #1 \if_int_compare:w \__int_eval:w #2 > \c_zero + \c_one \fi: @@ -2702,17 +2739,17 @@ \fi: ; } -\cs_new:Npn \__fp_div_mantissa_pack:NNN 1 #1 #2 { + #1 #2 ; } -\cs_new:Npn \__fp_div_mantissa_test_o:w 10 #1 +\cs_new:Npn \__fp_div_significand_pack:NNN 1 #1 #2 { + #1 #2 ; } +\cs_new:Npn \__fp_div_significand_test_o:w 10 #1 { \if_meaning:w 0 #1 - \exp_after:wN \__fp_div_mantissa_small_o:wwwNNNNwN + \exp_after:wN \__fp_div_significand_small_o:wwwNNNNwN \else: - \exp_after:wN \__fp_div_mantissa_large_o:wwwNNNNwN + \exp_after:wN \__fp_div_significand_large_o:wwwNNNNwN \fi: #1 } -\cs_new:Npn \__fp_div_mantissa_small_o:wwwNNNNwN +\cs_new:Npn \__fp_div_significand_small_o:wwwNNNNwN 0 #1; #2; #3; #4#5#6#7#8; #9 { \exp_after:wN \__fp_basics_pack_high:NNNNNw @@ -2722,7 +2759,7 @@ + \__fp_round:NNN #9 #7 #8 \exp_after:wN ; } -\cs_new:Npn \__fp_div_mantissa_large_o:wwwNNNNwN +\cs_new:Npn \__fp_div_significand_large_o:wwwNNNNwN #1; #2; #3; #4#5#6#7#8; #9 { + \c_one @@ -2736,13 +2773,13 @@ \__int_value:w \__fp_round_digit:Nw #7 #8 ; \exp_after:wN ; } -\cs_new:Npn \__fp_neg_o:w \s__fp \__fp_chk:w #1 #2 +\cs_new:Npn \__fp_neg_o:w #1 \s__fp \__fp_chk:w #2 #3 { \exp_after:wN \__fp_exp_after_o:w \exp_after:wN \s__fp \exp_after:wN \__fp_chk:w - \exp_after:wN #1 - \int_use:N \__int_eval:w \c_two - #2 \__int_eval_end: + \exp_after:wN #2 + \int_use:N \__int_eval:w \c_two - #3 \__int_eval_end: } \cs_new:Npn \__fp_abs_o:w \s__fp \__fp_chk:w #1 #2 { @@ -2788,6 +2825,12 @@ \tl_const:Nn \c__fp_one_fixed_tl { {10000} {0000} {0000} {0000} {0000} {0000} } \cs_new:Npn \__fp_fixed_continue:wn #1; #2 { #2 #1; } +\cs_new:Npn \__fp_fixed_add_one:wN #1#2; #3 + { + \exp_after:wN #3 \exp_after:wN + { \int_use:N \__int_eval:w \c_ten_thousand + #1 } #2 ; + } +\cs_new:Npn \__fp_fixed_mul_after:wn #1; #2 { #2 {#1} } \cs_new:Npn \__fp_fixed_div_int:wwN #1#2#3#4#5#6 ; #7 ; #8 { \exp_after:wN \__fp_fixed_div_int_after:Nw @@ -2799,7 +2842,7 @@ #3; {#7} \__fp_fixed_div_int_ii:wnn #4; {#7} \__fp_fixed_div_int_ii:wnn #5; {#7} \__fp_fixed_div_int_ii:wnn - #6; {#7} \__fp_fixed_div_int_end:wnn ; + #6; {#7} \__fp_fixed_div_int_iii:wnn ; } \cs_new:Npn \__fp_fixed_div_int_i:wnN #1; #2 #3 { @@ -2816,110 +2859,104 @@ \exp_after:wN \__fp_fixed_div_int_i:wnN \int_use:N \__int_eval:w #3 - #1*#2 \__int_eval_end: } -\cs_new:Npn \__fp_fixed_div_int_end:wnn #1; #2 #3 { + #1 + \c_two ; } +\cs_new:Npn \__fp_fixed_div_int_iii:wnn #1; #2 #3 { + #1 + \c_two ; } \cs_new:Npn \__fp_fixed_div_int_pack:Nw #1 #2; { + #1; {#2} } \cs_new:Npn \__fp_fixed_div_int_after:Nw #1 #2; { #1 {#2} } -\cs_new:Npn \__fp_fixed_add_one:wN #1#2; #3 - { - \exp_after:wN #3 \exp_after:wN - { \int_use:N \__int_eval:w 10000 + #1 } #2 ; - } -\cs_new_nopar:Npn \__fp_fixed_add:wwN { \__fp_fixed_add_i:NNnnnnwnn + + } -\cs_new_nopar:Npn \__fp_fixed_sub:wwN { \__fp_fixed_add_i:NNnnnnwnn + - } -\cs_new_nopar:Npn \__fp_fixed_sub_back:wwN { \__fp_fixed_add_i:NNnnnnwnn - + } -\cs_new:Npn \__fp_fixed_add_i:NNnnnnwnn #1#2 #3#4#5#6 #7; #8#9 - { - \exp_after:wN \__fp_fixed_add_after:NNNNNwN - \int_use:N \__int_eval:w 1 9999 9998 #1 #3#4 #2 #8#9 - \exp_after:wN \__fp_fixed_add_pack:NNNNNwN - \int_use:N \__int_eval:w 1 9999 9998 #1 #5#6 - \__fp_fixed_add_ii:NnnNnnnnw #1 #7 #2 - } -\cs_new:Npn \__fp_fixed_add_ii:NnnNnnnnw #1 #2#3 #4 #5#6 #7#8 ; #9 - { - #4 #5#6 - \exp_after:wN \__fp_fixed_add_pack:NNNNNwN - \int_use:N \__int_eval:w 2 0000 0000 #4 #7#8 #1 #2#3 ; #9 ; - } -\cs_new:Npn \__fp_fixed_add_pack:NNNNNwN #1 #2#3#4#5 #6; #7 - { + #1 ; #7 {#2#3#4#5} {#6} } -\cs_new:Npn \__fp_fixed_add_after:NNNNNwN #1 #2#3#4#5 #6; #7 - { - \exp_after:wN #7 - \exp_after:wN { \int_use:N \__int_eval:w - 2 0000 + #1#2#3#4#5 } - {#6} - } +\cs_new_nopar:Npn \__fp_fixed_add:wwn { \__fp_fixed_add_i:Nnnnnwnn + } +\cs_new_nopar:Npn \__fp_fixed_sub:wwn { \__fp_fixed_add_i:Nnnnnwnn - } +\cs_new:Npn \__fp_fixed_add_i:Nnnnnwnn #1 #2#3#4#5 #6; #7#8 + { + \exp_after:wN \__fp_fixed_add_after:NNNNNwn + \int_use:N \__int_eval:w 9 9999 9998 + #2#3 #1 #7#8 + \exp_after:wN \__fp_fixed_add_pack:NNNNNwn + \int_use:N \__int_eval:w 1 9999 9998 + #4#5 + \__fp_fixed_add_ii:nnNnnnwn #6 #1 + } +\cs_new:Npn \__fp_fixed_add_ii:nnNnnnwn #1#2 #3 #4#5 #6#7 ; #8 + { + #3 #4#5 + \exp_after:wN \__fp_fixed_add_pack:NNNNNwn + \int_use:N \__int_eval:w 2 0000 0000 #3 #6#7 + #1#2 ; {#8} ; + } +\cs_new:Npn \__fp_fixed_add_pack:NNNNNwn #1 #2#3#4#5 #6; #7 + { + #1 ; {#7} {#2#3#4#5} {#6} } +\cs_new:Npn \__fp_fixed_add_after:NNNNNwn 1 #1 #2#3#4#5 #6; #7 + { #7 {#1#2#3#4#5} {#6} } \cs_new:Npn \__fp_fixed_mul:wwn #1#2#3#4 #5; #6#7#8#9 { - \exp_after:wN \__fp_fixed_mul_after:wwn + \exp_after:wN \__fp_fixed_mul_after:wn \int_use:N \__int_eval:w \c__fp_leading_shift_int - \exp_after:wN \__fp_pack:NNNNNw + \exp_after:wN \__fp_pack:NNNNNwn \int_use:N \__int_eval:w \c__fp_middle_shift_int + #1*#6 - \exp_after:wN \__fp_pack:NNNNNw + \exp_after:wN \__fp_pack:NNNNNwn \int_use:N \__int_eval:w \c__fp_middle_shift_int + #1*#7 + #2*#6 - \exp_after:wN \__fp_pack:NNNNNw + \exp_after:wN \__fp_pack:NNNNNwn \int_use:N \__int_eval:w \c__fp_middle_shift_int + #1*#8 + #2*#7 + #3*#6 - \exp_after:wN \__fp_pack:NNNNNw + \exp_after:wN \__fp_pack:NNNNNwn \int_use:N \__int_eval:w \c__fp_middle_shift_int + #1*#9 + #2*#8 + #3*#7 + #4*#6 - \exp_after:wN \__fp_pack:NNNNNw + \exp_after:wN \__fp_pack:NNNNNwn \int_use:N \__int_eval:w \c__fp_trailing_shift_int + #2*#9 + #3*#8 + #4*#7 + ( #3*#9 + #4*#8 - + \__fp_fixed_mul_i:nnnnnnnn #5 {#6}{#7} {#1}{#2} - } -\cs_new:Npn \__fp_fixed_mul_i:nnnnnnnn #1#2 #3#4 #5#6 #7#8 - { #1*#4 + #2*#3 + #5*#8 + #6*#7 )/10000 + #1*#3 + #5*#7 ; } -\cs_new:Npn \__fp_fixed_mul_pack:NNNNNw - #1 #2#3#4#5 #6; { + #1#2#3#4#5 ; {#6} } -\cs_new:Npn \__fp_fixed_mul_after:wwn #1; #2; #3 { #3 {#1} #2 ; } -\cs_new:Npn \__fp_fixed_one_minus_mul:wwn #1; #2#3#4#5; - { - \exp_after:wN \__fp_fixed_mul_after:wwn - \int_use:N \__int_eval:w \c__fp_big_leading_shift_int + \c_ten_thousand - \exp_after:wN \__fp_pack_big:NNNNNNw + + \__fp_fixed_mul_i:nnnnnnnwn #5 {#6}{#7} {#1}{#2} + } +\cs_new:Npn \__fp_fixed_mul_i:nnnnnnnwn #1#2 #3#4 #5#6 #7#8 ; #9 + { + #1*#4 + #2*#3 + #5*#8 + #6*#7 ) / \c_ten_thousand + + #1*#3 + #5*#7 ; + {#9} ; + } +\cs_new:Npn \__fp_fixed_mul_add:wwwn #1; #2; #3#4#5#6#7#8; #9 + { + \exp_after:wN \__fp_fixed_mul_after:wn + \int_use:N \__int_eval:w \c__fp_big_leading_shift_int + \exp_after:wN \__fp_pack_big:NNNNNNwn + \int_use:N \__int_eval:w \c__fp_big_middle_shift_int + #3 #4 + \__fp_fixed_mul_add_i:Nwnnnwnnn + + + #5 #6 ; #2 ; #1 ; #2 ; + + + #7 #8 ; {#9} ; + } +\cs_new:Npn \__fp_fixed_mul_sub_back:wwwn #1; #2; #3#4#5#6#7#8; #9 + { + \exp_after:wN \__fp_fixed_mul_after:wn + \int_use:N \__int_eval:w \c__fp_big_leading_shift_int + \exp_after:wN \__fp_pack_big:NNNNNNwn + \int_use:N \__int_eval:w \c__fp_big_middle_shift_int + #3 #4 + \__fp_fixed_mul_add_i:Nwnnnwnnn - + + #5 #6 ; #2 ; #1 ; #2 ; - + + #7 #8 ; {#9} ; + } +\cs_new:Npn \__fp_fixed_one_minus_mul:wwn #1; #2; #3 + { + \exp_after:wN \__fp_fixed_mul_after:wn + \int_use:N \__int_eval:w \c__fp_big_leading_shift_int + \exp_after:wN \__fp_pack_big:NNNNNNwn + \int_use:N \__int_eval:w \c__fp_big_middle_shift_int + 1 0000 0000 + \__fp_fixed_mul_add_i:Nwnnnwnnn - + ; #2 ; #1 ; #2 ; - + ; {#3} ; + } +\cs_new:Npn \__fp_fixed_mul_add_i:Nwnnnwnnn #1 #2; #3#4#5#6; #7#8#9 + { + #1 #7*#3 + \exp_after:wN \__fp_pack_big:NNNNNNwn + \int_use:N \__int_eval:w \c__fp_big_middle_shift_int + #1 #7*#4 #1 #8*#3 + \exp_after:wN \__fp_pack_big:NNNNNNwn \int_use:N \__int_eval:w \c__fp_big_middle_shift_int - \__fp_fixed_mul_add_i:Nnwnnwnnn - - 00; {#2}{#3}{#4}; #1; {#2}{#3}{#4}#5; - 00 ; - } -\cs_new:Npn \__fp_fixed_mul_add:wwwn #1; #2#3#4#5; #6#7#8#9 - { - \exp_after:wN \__fp_fixed_mul_after:wwn - \int_use:N \__int_eval:w \c__fp_big_leading_shift_int + #6 - \exp_after:wN \__fp_pack_big:NNNNNNw - \int_use:N \__int_eval:w \c__fp_big_middle_shift_int + #7 - \__fp_fixed_mul_add_i:Nnwnnwnnn - + {#8}{#9}; {#2}{#3}{#4}; #1; {#2}{#3}{#4}#5; + - } -\cs_new:Npn \__fp_fixed_mul_sub_back:wwwn #1; #2#3#4#5; #6#7#8#9 - { - \exp_after:wN \__fp_fixed_mul_after:wwn - \int_use:N \__int_eval:w \c__fp_big_leading_shift_int + #6 - \exp_after:wN \__fp_pack_big:NNNNNNw - \int_use:N \__int_eval:w \c__fp_big_middle_shift_int + #7 - \__fp_fixed_mul_add_i:Nnwnnwnnn - - {#8}{#9}; {#2}{#3}{#4}; #1; {#2}{#3}{#4}#5; - - } -\cs_new:Npn \__fp_fixed_mul_add_i:Nnwnnwnnn #1 #2#3; #4#5#6; #7#8#9 - { % sg z3z4; y1y2y3; x1x2x3 x4x5x6; y1y2y3y4y5y6; sg z5z6; - #1 #7*#4 - \exp_after:wN \__fp_pack_big:NNNNNNw - \int_use:N \__int_eval:w \c__fp_big_middle_shift_int + #2 - #1 #7*#5 #1 #8*#4 - \exp_after:wN \__fp_pack_big:NNNNNNw - \int_use:N \__int_eval:w \c__fp_big_middle_shift_int + #3 - #1 #7*#6 #1 #8*#5 #1 #9*#4 - \exp_after:wN \__fp_pack_big:NNNNNNw - \int_use:N \__int_eval:w \c__fp_big_middle_shift_int - #1 \__fp_fixed_mul_add_ii:nnnnwnnnn {#7}{#8}{#9} + #1 #7*#5 #1 #8*#4 #1 #9*#3 #2 + \exp_after:wN \__fp_pack_big:NNNNNNwn + \int_use:N \__int_eval:w \c__fp_big_middle_shift_int + #1 \__fp_fixed_mul_add_ii:nnnnwnnnn {#7}{#8}{#9} } \cs_new:Npn \__fp_fixed_mul_add_ii:nnnnwnnnn #1#2#3#4#5; #6#7#8#9 - { % x1x2x3x4 x5x6; y1y2y3y4 y5y6; sg z5z6; + { ( #1*#9 + #2*#8 + #3*#7 + #4*#6 ) - \exp_after:wN \__fp_pack_big:NNNNNNw + \exp_after:wN \__fp_pack_big:NNNNNNwn \int_use:N \__int_eval:w \c__fp_big_trailing_shift_int \__fp_fixed_mul_add_iii:nnnnwnnwN { #6 + #4*#7 + #3*#8 + #2*#9 + #1 } @@ -2928,15 +2965,9 @@ {#6} } \cs_new:Npn \__fp_fixed_mul_add_iii:nnnnwnnwN #1#2 #3#4#5; #6#7#8; #9 - { % {y1+x4*y2+x3*y3+x2*y4+x1} {y2+x4*y3+x3*y4+x2} - % x1x5x6; y1y5y6; sg z5z6; - % => - % sg (x5*y1+x4*y2+x3*y3+x2*y4+x1*y5) - % sg (x6*y1+x5*y2+x4*y3+x3*y4+x2*y5+x1*y6)/10000 - % + z5z6; + { #9 (#4* #1 *#7) #9 (#5*#6+#4* #2 *#7+#3*#8) / \c_ten_thousand - + \__fp_use_s:nn } \cs_new:Npn \__fp_fixed_to_float:Nw #1#2; { \__fp_fixed_to_float:wN #2; #1 } \cs_new:Npn \__fp_fixed_to_float:wN #1#2#3#4#5#6; #7 @@ -2996,7 +3027,7 @@ } \cs_new:Npn \__fp_fixed_inv_to_float:wN #1#2; #3 { - - \__int_eval:w + + \__int_eval:w % ^^A todo: remove the +? \if_int_compare:w #1 < \c_one_thousand \__fp_fixed_dtf_zeros:wNnnnnnn \fi: @@ -3092,7 +3123,7 @@ { #1 ; {#2#3#4#5} {#6} } \cs_new:Npn \__fp_fixed_dtf_epsilon_ii:NNNNNww #1#2#3#4#5#6; #7; { - \__fp_fixed_mul:wwn %^^A todo: optimize to use \__fp_mul_mantissa. + \__fp_fixed_mul:wwn %^^A todo: optimize to use \__fp_mul_significand. {0000} {#2#3#4#5} {#6} #7 ; {0000} {#2#3#4#5} {#6} #7 ; \__fp_fixed_add_one:wN @@ -3209,7 +3240,7 @@ } \cs_new:Npn \__fp_ln_x_iv:wnnnnnnnn #1; #2#3#4#5 #6#7#8#9 { - \exp_after:wN \__fp_div_mantissa_pack:NNN + \exp_after:wN \__fp_div_significand_pack:NNN \int_use:N \__int_eval:w \__fp_ln_div_i:w #1 ; #6 #7 ; {#8} {#9} @@ -3222,20 +3253,20 @@ } \cs_new:Npn \__fp_ln_div_i:w #1; { - \exp_after:wN \__fp_div_mantissa_calc:wwnnnnnnn + \exp_after:wN \__fp_div_significand_calc:wwnnnnnnn \int_use:N \__int_eval:w 999999 + 2 0000 0000 / #1 ; % Q1 } \cs_new:Npn \__fp_ln_div_ii:wwn #1; #2;#3 % y; B1;B2 <- for k=1 { - \exp_after:wN \__fp_div_mantissa_pack:NNN + \exp_after:wN \__fp_div_significand_pack:NNN \int_use:N \__int_eval:w - \exp_after:wN \__fp_div_mantissa_calc:wwnnnnnnn + \exp_after:wN \__fp_div_significand_calc:wwnnnnnnn \int_use:N \__int_eval:w 999999 + #2 #3 / #1 ; % Q2 #2 #3 ; } \cs_new:Npn \__fp_ln_div_vi:wwn #1; #2;#3#4#5 #6#7#8#9 %y;F1;F2F3F4x1x2x3x4 { - \exp_after:wN \__fp_div_mantissa_pack:NNN + \exp_after:wN \__fp_div_significand_pack:NNN \int_use:N \__int_eval:w 1000000 + #2 #3 / #1 ; % Q6 } \cs_new:Npn \__fp_ln_div_after:Nw #1#2; @@ -3303,7 +3334,7 @@ \__fp_ln_Taylor_break:w \fi: \exp_after:wN \__fp_fixed_div_int:wwN \c__fp_one_fixed_tl ; #1; - \__fp_fixed_add:wwN #2; + \__fp_fixed_add:wwn #2; \__fp_fixed_mul:wwn #3; { \exp_after:wN \__fp_ln_Taylor_loop:www @@ -3311,7 +3342,7 @@ } #3; } -\cs_new:Npn \__fp_ln_Taylor_break:w \fi: #1 \__fp_fixed_add:wwN #2#3; #4 ;; +\cs_new:Npn \__fp_ln_Taylor_break:w \fi: #1 \__fp_fixed_add:wwn #2#3; #4 ;; { \fi: \exp_after:wN \__fp_fixed_mul:wwn @@ -3320,9 +3351,9 @@ \cs_new:Npn \__fp_ln_c:NwNw #1 #2; #3 { \if_meaning:w + #1 - \exp_after:wN \exp_after:wN \exp_after:wN \__fp_fixed_sub:wwN + \exp_after:wN \exp_after:wN \exp_after:wN \__fp_fixed_sub:wwn \else: - \exp_after:wN \exp_after:wN \exp_after:wN \__fp_fixed_add:wwN + \exp_after:wN \exp_after:wN \exp_after:wN \__fp_fixed_add:wwn \fi: #3 ; #2 ; } @@ -3336,11 +3367,11 @@ \if_int_compare:w #2 > \c_zero \exp_after:wN \__fp_ln_exponent_small:NNww \exp_after:wN 0 - \exp_after:wN \__fp_fixed_sub:wwN \__int_value:w + \exp_after:wN \__fp_fixed_sub:wwn \__int_value:w \else: \exp_after:wN \__fp_ln_exponent_small:NNww \exp_after:wN 2 - \exp_after:wN \__fp_fixed_add:wwN \__int_value:w - + \exp_after:wN \__fp_fixed_add:wwn \__int_value:w - \fi: \fi: #2; #1; @@ -3348,7 +3379,7 @@ \cs_new:Npn \__fp_ln_exponent_one:ww 1; #1; { \c_zero - \exp_after:wN \__fp_fixed_sub:wwN \c__fp_ln_x_fixed_tl ; #1; + \exp_after:wN \__fp_fixed_sub:wwn \c__fp_ln_x_fixed_tl ; #1; \__fp_fixed_to_float:wN 0 } \cs_new:Npn \__fp_ln_exponent_small:NNww #1#2#3; #4#5#6#7#8#9; @@ -3421,7 +3452,7 @@ } #5 {#4} - #2 0 + #1 #2 0 \tex_romannumeral:D \fi: \fi: @@ -3429,8 +3460,9 @@ } \cs_new:Npn \__fp_exp_overflow: { + \c_two * \c__fp_max_exponent_int ; {1000} {0000} {0000} {0000} ; } -\cs_new:Npn \__fp_exp_Taylor:Nnnwn #1#2#3 #4; #5 +\cs_new:Npn \__fp_exp_Taylor:Nnnwn #1#2#3 #4; #5 #6 { + #6 \__fp_pack_twice_four:wNNNNNNNN \__fp_pack_twice_four:wNNNNNNNN \__fp_pack_twice_four:wNNNNNNNN @@ -3562,9 +3594,9 @@ #1; \__fp_exp_large_after:wwn } -\cs_new:Npn \__fp_exp_large_after:wwn #1; #2; +\cs_new:Npn \__fp_exp_large_after:wwn #1; #2; #3 { - \__fp_exp_Taylor:Nnnwn ? { } { } 0 #2; {} + \__fp_exp_Taylor:Nnnwn ? { } { } 0 #2; {} #3 \__fp_fixed_mul:wwn #1; } \cs_new:cpn { __fp_ \iow_char:N \^ _o:ww } @@ -3599,6 +3631,13 @@ \fi: \if_meaning:w #1 #4 \__fp_case_return_o:Nw \c_zero_fp + \fi: + \if_meaning:w 0 #1 + \__fp_case_use:nw + { + \__fp_division_by_zero_o:NNww \c_inf_fp ^ + \s__fp \__fp_chk:w #1 #2 ; + } \else: \__fp_case_return_o:Nw \c_inf_fp \fi: @@ -3613,7 +3652,7 @@ \fi: \__fp_case_return_o:Nww \c_one_fp \fi: - \if_case:w #4 ~ + \if_case:w #4 \exp_stop_f: \or: \exp_after:wN \__fp_pow_npos:Nww \exp_after:wN #5 @@ -3638,50 +3677,57 @@ \exp_after:wN 0 \__int_value:w \if:w #1 \if_int_compare:w #3 > \c_zero 0 \else: 2 \fi: - \exp_after:wN \__fp_pow_npos_aux:Nnww + \exp_after:wN \__fp_pow_npos_aux:NNnww + \exp_after:wN + \exp_after:wN \__fp_fixed_to_float:wN \else: - - - \exp_after:wN \__fp_pow_npos_aux:Nnww + \exp_after:wN \__fp_pow_npos_aux:NNnww + \exp_after:wN - \exp_after:wN \__fp_fixed_inv_to_float:wN \fi: {#3} } -\cs_new:Npn \__fp_pow_npos_aux:Nnww #1#2#3#4; \s__fp \__fp_chk:w 1#5#6#7; +\cs_new:Npn \__fp_pow_npos_aux:NNnww #1#2#3#4#5; \s__fp \__fp_chk:w 1#6#7#8; { + #1 \__int_eval:w - \__fp_ln_significand:NNNNnnnN #3#4 - \__fp_pow_exponent:wnN {#2} - \__fp_fixed_mul:wwn #7 {0000}{0000} ; - \__fp_pow_B:wwN #6; - #1 0 % fixed_to_float:wN + \__fp_ln_significand:NNNNnnnN #4#5 + \__fp_pow_exponent:wnN {#3} + \__fp_fixed_mul:wwn #8 {0000}{0000} ; + \__fp_pow_B:wwN #7; + #1 #2 0 % fixed_to_float:wN } \cs_new:Npn \__fp_pow_exponent:wnN #1; #2 { \if_int_compare:w #2 > \c_zero - \exp_after:wN \__fp_pow_exponent:Nwnnnnnn % n\ln(10) - (-\ln(x)) + \exp_after:wN \__fp_pow_exponent:Nwnnnnnwn % n\ln(10) - (-\ln(x)) \exp_after:wN + \else: - \exp_after:wN \__fp_pow_exponent:Nwnnnnnn % -( |n|\ln(10) + (-\ln(x)) ) + \exp_after:wN \__fp_pow_exponent:Nwnnnnnwn % -( |n|\ln(10) + (-\ln(x)) ) \exp_after:wN - \fi: #2; #1; } -\cs_new:Npn \__fp_pow_exponent:Nwnnnnnn #1#2; #3#4#5#6#7#8; - { %^^A todo: use that in ln. %^^A todo: log(1.00...) too inaccurate? - \exp_after:wN \__fp_fixed_mul_after:wwn - \int_use:N \__int_eval:w -5 0000 - \exp_after:wN \__fp_fixed_mul_pack:NNNNNw - \int_use:N \__int_eval:w 4 9995 0000 #1#2*23025 - #1 #3 - \exp_after:wN \__fp_fixed_mul_pack:NNNNNw - \int_use:N \__int_eval:w 4 9995 0000 #1 #2*8509 - #1 #4 - \exp_after:wN \__fp_fixed_mul_pack:NNNNNw - \int_use:N \__int_eval:w 4 9995 0000 #1 #2*2994 - #1 #5 - \exp_after:wN \__fp_fixed_mul_pack:NNNNNw - \int_use:N \__int_eval:w 4 9995 0000 #1 #2*0456 - #1 #6 - \exp_after:wN \__fp_fixed_mul_pack:NNNNNw - \int_use:N \__int_eval:w 5 0000 0000 #1 #2*8401 - #1 #7 - #1 ( #2*7991 - #8 ) / 1 0000 ; ; +\cs_new:Npn \__fp_pow_exponent:Nwnnnnnwn #1#2; #3#4#5#6#7#8; #9 + { %^^A todo: use that in ln. + \exp_after:wN \__fp_fixed_mul_after:wn + \int_use:N \__int_eval:w \c__fp_leading_shift_int + \exp_after:wN \__fp_pack:NNNNNwn + \int_use:N \__int_eval:w \c__fp_middle_shift_int + #1#2*23025 - #1 #3 + \exp_after:wN \__fp_pack:NNNNNwn + \int_use:N \__int_eval:w \c__fp_middle_shift_int + #1 #2*8509 - #1 #4 + \exp_after:wN \__fp_pack:NNNNNwn + \int_use:N \__int_eval:w \c__fp_middle_shift_int + #1 #2*2994 - #1 #5 + \exp_after:wN \__fp_pack:NNNNNwn + \int_use:N \__int_eval:w \c__fp_middle_shift_int + #1 #2*0456 - #1 #6 + \exp_after:wN \__fp_pack:NNNNNwn + \int_use:N \__int_eval:w \c__fp_trailing_shift_int + #1 #2*8401 - #1 #7 + #1 ( #2*7991 - #8 ) / 1 0000 ; {#9} ; } \cs_new:Npn \__fp_pow_B:wwN #1#2#3#4#5#6; #7; { @@ -3698,7 +3744,7 @@ \int_use:N \__int_eval:w 10 0000 + #1 \__int_eval_end: #2#3#4#5#6 0000 0000 0000 0000 0000 0000 ; %^^A todo: how many 0? } -\cs_new:Npn \__fp_pow_C_overflow:w #1; #2; +\cs_new:Npn \__fp_pow_C_overflow:w #1; #2; #3 { + \c_two * \c__fp_max_exponent_int \exp_after:wN \__fp_fixed_continue:wn \c__fp_one_fixed_tl ; @@ -3729,7 +3775,7 @@ \cs_new:Npn \__fp_pow_neg:www \s__fp \__fp_chk:w #1#2; #3; #4; { \if_case:w \__fp_pow_neg_case:w #4 ; - \exp_after:wN \__fp_pow_neg_neg:w + \exp_after:wN \__fp_neg_o:w \or: \if_int_compare:w \__int_eval:w #1 / \c_two = \c_one \__fp_invalid_operation_o:Nww ^ #3; #4; @@ -3741,14 +3787,6 @@ \__fp_exp_after_o:w \s__fp \__fp_chk:w #1#2; } -\cs_new:Npn \__fp_pow_neg_neg:w \__fp_exp_after_o:w \s__fp \__fp_chk:w #1#2 - { - \exp_after:wN \__fp_exp_after_o:w - \exp_after:wN \s__fp - \exp_after:wN \__fp_chk:w - \exp_after:wN #1 - \int_use:N \__int_eval:w \c_two - #2 \__int_eval_end: - } \cs_new:Npn \__fp_pow_neg_case:w \s__fp \__fp_chk:w #1#2#3; { \if_case:w #1 \exp_stop_f: @@ -3826,24 +3864,17 @@ %% %% ----------------------------------------------------------------------- %% -\cs_new_nopar:Npx \__fp_one_over:w - { - \exp_not:N \exp_after:wN - \exp_not:c { __fp_/_o:ww } - \exp_not:N \c_one_fp - } \cs_new:Npn \__fp_sin_o:w \s__fp \__fp_chk:w #1#2 { \if_case:w #1 \exp_stop_f: \__fp_case_return_same_o:w \or: - \exp_after:wN \__fp_trig_exponent:NNNNwn - \exp_after:wN \__fp_sin_series:NNwww - \exp_after:wN ? - \exp_after:wN #2 - \exp_after:wN \c_zero - \or: - \__fp_case_use:nw { \__fp_invalid_operation_o:nw { sin } } + \__fp_case_use:nw + { + \__fp_trig_exponent:NNNNNwn \__fp_trig_epsilon_o:w + \__fp_sin_series:NNwww \__fp_fixed_to_float:wN #2 \c_zero + } + \or: \__fp_case_use:nw { \__fp_invalid_operation_o:nw { sin } } \else: \__fp_case_return_same_o:w \fi: \s__fp \__fp_chk:w #1#2 @@ -3853,16 +3884,42 @@ \if_case:w #1 \exp_stop_f: \__fp_case_return_o:Nw \c_one_fp \or: - \__fp_case_use:nw %^^A todo: is that faster than the exp_after route? + \__fp_case_use:nw { - \__fp_trig_exponent:NNNNwn - \__fp_sin_series:NNwww - ? - 0 - \c_two + \__fp_trig_exponent:NNNNNwn \__fp_trig_epsilon_one_o:w + \__fp_sin_series:NNwww \__fp_fixed_to_float:wN 0 \c_two } + \or: \__fp_case_use:nw { \__fp_invalid_operation_o:nw { cos } } + \else: \__fp_case_return_same_o:w + \fi: + \s__fp \__fp_chk:w #1#2 + } +\cs_new:Npn \__fp_csc_o:w \s__fp \__fp_chk:w #1#2 + { + \if_case:w #1 \exp_stop_f: + \__fp_cot_zero_o:Nnw #2 { csc } + \or: + \__fp_case_use:nw + { + \__fp_trig_exponent:NNNNNwn \__fp_trig_epsilon_inv_o:w + \__fp_sin_series:NNwww \__fp_fixed_inv_to_float:wN #2 \c_zero + } + \or: \__fp_case_use:nw { \__fp_invalid_operation_o:nw { csc } } + \else: \__fp_case_return_same_o:w + \fi: + \s__fp \__fp_chk:w #1#2 + } +\cs_new:Npn \__fp_sec_o:w \s__fp \__fp_chk:w #1#2 + { + \if_case:w #1 \exp_stop_f: + \__fp_case_return_o:Nw \c_one_fp \or: - \__fp_case_use:nw { \__fp_invalid_operation_o:nw { cos } } + \__fp_case_use:nw + { + \__fp_trig_exponent:NNNNNwn \__fp_trig_epsilon_one_o:w + \__fp_sin_series:NNwww \__fp_fixed_inv_to_float:wN 0 \c_two + } + \or: \__fp_case_use:nw { \__fp_invalid_operation_o:nw { sec } } \else: \__fp_case_return_same_o:w \fi: \s__fp \__fp_chk:w #1#2 @@ -3872,13 +3929,12 @@ \if_case:w #1 \exp_stop_f: \__fp_case_return_same_o:w \or: - \exp_after:wN \__fp_trig_exponent:NNNNwn - \exp_after:wN \__fp_tan_series:NNwww - \exp_after:wN 0 - \exp_after:wN #2 - \exp_after:wN \c_one - \or: - \__fp_case_use:nw { \__fp_invalid_operation_o:nw { tan } } + \__fp_case_use:nw + { + \__fp_trig_exponent:NNNNNwn \__fp_trig_epsilon_o:w + \__fp_tan_series_o:NNwww 0 #2 \c_one + } + \or: \__fp_case_use:nw { \__fp_invalid_operation_o:nw { tan } } \else: \__fp_case_return_same_o:w \fi: \s__fp \__fp_chk:w #1#2 @@ -3886,129 +3942,126 @@ \cs_new:Npn \__fp_cot_o:w \s__fp \__fp_chk:w #1#2 { \if_case:w #1 \exp_stop_f: - \exp_after:wN \__fp_one_over:w - \or: - \exp_after:wN \__fp_trig_exponent:NNNNwn - \exp_after:wN \__fp_tan_series:NNwww - \exp_after:wN 2 - \exp_after:wN #2 - \exp_after:wN \c_three + \__fp_cot_zero_o:Nnw #2 { cot } \or: - \__fp_case_use:nw { \__fp_invalid_operation_o:nw { cot } } + \__fp_case_use:nw + { + \__fp_trig_exponent:NNNNNwn \__fp_trig_epsilon_inv_o:w + \__fp_tan_series_o:NNwww 2 #2 \c_three + } + \or: \__fp_case_use:nw { \__fp_invalid_operation_o:nw { cot } } \else: \__fp_case_return_same_o:w \fi: \s__fp \__fp_chk:w #1#2 } -\cs_new:Npn \__fp_trig_exponent:NNNNwn #1#2#3#4 \s__fp \__fp_chk:w 1#5#6 +\cs_new:Npn \__fp_cot_zero_o:Nnw #1 #2 #3 \fi: { - \if_int_compare:w #6 > - \c_eight - \exp_after:wN #1 + \fi: + \if_meaning:w 0 #1 + \exp_after:wN \__fp_division_by_zero_o:Nnw \exp_after:wN \c_inf_fp + \else: + \exp_after:wN \__fp_division_by_zero_o:Nnw \exp_after:wN \c_minus_inf_fp + \fi: + {#2} + } +\cs_new:Npn \__fp_trig_exponent:NNNNNwn #1#2#3#4#5 \s__fp \__fp_chk:w 1#6#7 + { + \if_int_compare:w #7 > - \c_eight \exp_after:wN #2 \exp_after:wN #3 - \int_use:N \__int_eval:w #4 - \if_int_compare:w #6 > \c_zero - \exp_after:wN \__fp_trig_large:w \__int_value:w + \exp_after:wN #4 + \int_use:N \__int_eval:w #5 + \if_int_compare:w #7 > \c_zero + \exp_after:wN \__fp_trig_large:ww \__int_value:w \else: - \exp_after:wN \__fp_trig_small:w \__int_value:w + \exp_after:wN \__fp_trig_small:ww \__int_value:w \fi: \else: - \if_case:w #4 - \__fp_sin_epsilon:w - \or: \__fp_sin_epsilon:w - \or: \__fp_cos_epsilon:w - \else: \__fp_cot_epsilon:w - \fi: - #5 + \exp_after:wN #1 + \exp_after:wN #6 \fi: - #6 ; - } -\cs_new:Npn \__fp_sin_epsilon:w #1 \fi: #2 \fi: #3 ; - { \fi: \fi: \__fp_exp_after_o:w \s__fp \__fp_chk:w 1 #2 {#3} } -\cs_new:Npn \__fp_cos_epsilon:w #1 \fi: #2 \fi: #3 ; #4 ; - { \fi: \fi: \exp_after:wN \c_one_fp } -\cs_new:Npn \__fp_cot_epsilon:w \fi: #1 \fi: #2 ; - { \fi: \fi: \__fp_one_over:w \s__fp \__fp_chk:w 1 #1 {#2} } -\cs_new:Npn \__fp_trig_small:w #1; - { - \exp_after:wN \exp_after:wN \exp_after:wN \__fp_trig_small_aux:wwNN - \prg_replicate:nn { - #1 } { 0 } ; + #7 ; } -\cs_new:Npn \__fp_trig_small_aux:wwNN #1; #2#3#4#5; +\cs_new:Npn \__fp_trig_epsilon_o:w #1 #2 ; + { \__fp_exp_after_o:w \s__fp \__fp_chk:w 1 #1 {#2} } +\cs_new:Npn \__fp_trig_epsilon_one_o:w #1 ; #2 ; + { \exp_after:wN \c_one_fp } +\group_begin: + \char_set_catcode_letter:N / + \cs_new:Npn \__fp_trig_epsilon_inv_o:w #1 #2 ; + { + \exp_after:wN \__fp_/_o:ww + \c_one_fp + \s__fp \__fp_chk:w 1 #1 {#2} + } +\group_end: +\cs_new:Npn \__fp_trig_small:ww #1; #2#3#4#5; { - \__fp_pack_twice_four:wNNNNNNNN - \__fp_pack_twice_four:wNNNNNNNN - \__fp_pack_twice_four:wNNNNNNNN - . - ; - #1#2#3#4#5 0000 0000; + \exp_after:wN \__fp_pack_twice_four:wNNNNNNNN + \exp_after:wN \__fp_pack_twice_four:wNNNNNNNN + \exp_after:wN \__fp_pack_twice_four:wNNNNNNNN + \exp_after:wN . + \exp_after:wN ; + \tex_romannumeral:D -`0 + \prg_replicate:nn { - #1 } { 0 } #2#3#4#5 0000 0000 ; } -\cs_new:Npn \__fp_trig_large:w #1; #2#3; +\cs_new:Npn \__fp_trig_large:ww #1; #2#3; { \__fp_trig_large_i:www #2; #3 ; #1; } \cs_new:Npn \__fp_trig_large_i:www #1; #2; #3; { \if_meaning:w 0 #3 \__fp_trig_large_break:w \fi: - \exp_after:wN \__fp_trig_large_ii:wnnnnnn + \exp_after:wN \__fp_trig_large_ii_o:wnnnn \int_use:N \__int_eval:w ( #1 - 3141 ) / 6283 ; - {#1} #2; + {#1} #2 + \exp_after:wN ; \int_use:N \__int_eval:w \c_minus_one + #3; } -\cs_new:Npn \__fp_trig_large_ii:wnnnnnn #1; #2#3#4#5; +\cs_new:Npn \__fp_trig_large_ii_o:wnnnn #1; #2#3#4#5 { \exp_after:wN \__fp_trig_large_i:www - \int_use:N \__int_eval:w -5 0000 + #20 - #1*62831 - \exp_after:wN \__fp_fixed_mul_pack:NNNNNw - \int_use:N \__int_eval:w 4 9995 0000 + #30 - #1*8530 - \exp_after:wN \__fp_fixed_mul_pack:NNNNNw - \int_use:N \__int_eval:w 4 9995 0000 + #40 - #1*7179 - \exp_after:wN \__fp_fixed_mul_pack:NNNNNw - \int_use:N \__int_eval:w 5 0000 0000 + #50 - #1*5880 - \exp_after:wN ; + \int_use:N \__int_eval:w \c__fp_leading_shift_int + #20 - #1*62831 + \exp_after:wN \__fp_pack:NNNNNw + \int_use:N \__int_eval:w \c__fp_middle_shift_int + #30 - #1*8530 + \exp_after:wN \__fp_pack:NNNNNw + \int_use:N \__int_eval:w \c__fp_middle_shift_int + #40 - #1*7179 + \exp_after:wN \__fp_pack:NNNNNw + \int_use:N \__int_eval:w \c__fp_trailing_shift_int + #50 - #1*5880 \exp_after:wN ; } \cs_new:Npn \__fp_trig_large_break:w \fi: #1; #2; - { \fi: \__fp_trig_octant_loop:nw #2 {0000} {0000} ; } -\cs_new:Npn \__fp_trig_octant_loop:nw #1#2; + { \fi: \__fp_trig_octant_loop:nnnnnw #2 {0000} {0000} ; } +\cs_new:Npn \__fp_trig_octant_loop:nnnnnw #1#2#3#4#5#6; { - \if_int_compare:w #1 < 15707 \exp_stop_f: + \if_int_compare:w #1#2 < 157079633 \exp_stop_f: + \if_int_compare:w #1#2 = 157079632 \exp_stop_f: + \if_int_compare:w #3#4 > 67948969 \exp_stop_f: + \use_i_ii:nnn + \fi: + \fi: \__fp_trig_octant_break:w \fi: + \c_two - \__fp_fixed_sub_back:wwN + \__fp_fixed_sub:wwn + {#1} {#2} {#3} {#4} {0000} {0000} ; {15707} {9632} {6794} {8970} {0000} {0000} ; - {#1} #2; - \__fp_trig_octant_loop:nw + \__fp_trig_octant_loop:nnnnnw } -\cs_new:Npn \__fp_trig_octant_break:w #1 \fi: + #2#3 #4; #5#6; #7; +\cs_new:Npn \__fp_trig_octant_break:w #1 \fi: + #2#3 #4#5; #6; #7; { \fi: - \if_int_compare:w #5 < 7854 \exp_stop_f: - \if_int_compare:w #5 < \c_zero - \exp_after:wN \__fp_trig_octant_neg:w - \fi: + \if_int_compare:w #4 < 7854 \exp_stop_f: \exp_after:wN \__fp_use_i_until_s:nw \exp_after:wN . \fi: + \c_one - \__fp_fixed_sub:wwN - {15707} {9632} {6794} {8970} {0000} {0000} ; - {#5} #6 ; . ; - } -\cs_new:Npn \__fp_trig_octant_neg:w #1\fi: #2; #3#4#5#6#7#8; #9 - { - \fi: - + \c_seven - \exp_after:wN \__fp_fixed_add_after:NNNNNwN - \int_use:N \__int_eval:w 1 9999 9998 - #30000 - #4 - \exp_after:wN \__fp_fixed_add_pack:NNNNNwN - \int_use:N \__int_eval:w 1 9999 9998 - #5#6 - \exp_after:wN \__fp_fixed_add_pack:NNNNNwN - \int_use:N \__int_eval:w 2 0000 0000 - #7#8 ; {#9} ; + \__fp_fixed_sub:wwn #6 ; {#4} #5 ; . ; } \cs_new:Npn \__fp_sin_series:NNwww #1#2#3 . #4; #5; { \__fp_fixed_mul:wwn #4; #4; { - \exp_after:wN \__fp_sin_series_aux:Nnww + \exp_after:wN \__fp_sin_series_aux:NNnww + \exp_after:wN #1 \__int_value:w \if_int_odd:w \__int_eval:w ( #3 + \c_two ) / \c_four \__int_eval_end: #2 @@ -4019,49 +4072,49 @@ } #4 ; } -\cs_new:Npn \__fp_sin_series_aux:Nnww #1#2 #3; #4; +\cs_new:Npn \__fp_sin_series_aux:NNnww #1#2#3 #4; #5; { - \if_int_odd:w \__int_eval:w #2 / \c_two \__int_eval_end: + \if_int_odd:w \__int_eval:w #3 / \c_two \__int_eval_end: \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn \fi: - { - \__fp_fixed_continue:wn {0000}{0000}{0000}{0001}{5619}{2070}; % 1/18! - \__fp_fixed_mul_sub_back:wwwn #3; {0000}{0000}{0000}{0477}{9477}{3324}; - \__fp_fixed_mul_sub_back:wwwn #3; {0000}{0000}{0011}{4707}{4559}{7730}; - \__fp_fixed_mul_sub_back:wwwn #3; {0000}{0000}{2087}{6756}{9878}{6810}; - \__fp_fixed_mul_sub_back:wwwn #3; {0000}{0027}{5573}{1922}{3985}{8907}; - \__fp_fixed_mul_sub_back:wwwn #3; {0000}{2480}{1587}{3015}{8730}{1587}; - \__fp_fixed_mul_sub_back:wwwn #3; {0013}{8888}{8888}{8888}{8888}{8889}; - \__fp_fixed_mul_sub_back:wwwn #3; {0416}{6666}{6666}{6666}{6666}{6667}; - \__fp_fixed_mul_sub_back:wwwn #3; {5000}{0000}{0000}{0000}{0000}{0000}; - \__fp_fixed_mul_sub_back:wwwn #3;{10000}{0000}{0000}{0000}{0000}{0000}; + { % 1/18! + \__fp_fixed_mul_sub_back:wwwn {0000}{0000}{0000}{0001}{5619}{2070}; + #4; {0000}{0000}{0000}{0477}{9477}{3324}; + \__fp_fixed_mul_sub_back:wwwn #4; {0000}{0000}{0011}{4707}{4559}{7730}; + \__fp_fixed_mul_sub_back:wwwn #4; {0000}{0000}{2087}{6756}{9878}{6810}; + \__fp_fixed_mul_sub_back:wwwn #4; {0000}{0027}{5573}{1922}{3985}{8907}; + \__fp_fixed_mul_sub_back:wwwn #4; {0000}{2480}{1587}{3015}{8730}{1587}; + \__fp_fixed_mul_sub_back:wwwn #4; {0013}{8888}{8888}{8888}{8888}{8889}; + \__fp_fixed_mul_sub_back:wwwn #4; {0416}{6666}{6666}{6666}{6666}{6667}; + \__fp_fixed_mul_sub_back:wwwn #4; {5000}{0000}{0000}{0000}{0000}{0000}; + \__fp_fixed_mul_sub_back:wwwn #4;{10000}{0000}{0000}{0000}{0000}{0000}; } - { - \__fp_fixed_continue:wn {0000}{0000}{0000}{0028}{1145}{7254}; % 1/17! - \__fp_fixed_mul_sub_back:wwwn #3; {0000}{0000}{0000}{7647}{1637}{3182}; - \__fp_fixed_mul_sub_back:wwwn #3; {0000}{0000}{0160}{5904}{3836}{8216}; - \__fp_fixed_mul_sub_back:wwwn #3; {0000}{0002}{5052}{1083}{8544}{1719}; - \__fp_fixed_mul_sub_back:wwwn #3; {0000}{0275}{5731}{9223}{9858}{9065}; - \__fp_fixed_mul_sub_back:wwwn #3; {0001}{9841}{2698}{4126}{9841}{2698}; - \__fp_fixed_mul_sub_back:wwwn #3; {0083}{3333}{3333}{3333}{3333}{3333}; - \__fp_fixed_mul_sub_back:wwwn #3; {1666}{6666}{6666}{6666}{6666}{6667}; - \__fp_fixed_mul_sub_back:wwwn #3;{10000}{0000}{0000}{0000}{0000}{0000}; - \__fp_fixed_mul:wwn #4; + { % 1/17! + \__fp_fixed_mul_sub_back:wwwn {0000}{0000}{0000}{0028}{1145}{7254}; + #4; {0000}{0000}{0000}{7647}{1637}{3182}; + \__fp_fixed_mul_sub_back:wwwn #4; {0000}{0000}{0160}{5904}{3836}{8216}; + \__fp_fixed_mul_sub_back:wwwn #4; {0000}{0002}{5052}{1083}{8544}{1719}; + \__fp_fixed_mul_sub_back:wwwn #4; {0000}{0275}{5731}{9223}{9858}{9065}; + \__fp_fixed_mul_sub_back:wwwn #4; {0001}{9841}{2698}{4126}{9841}{2698}; + \__fp_fixed_mul_sub_back:wwwn #4; {0083}{3333}{3333}{3333}{3333}{3333}; + \__fp_fixed_mul_sub_back:wwwn #4; {1666}{6666}{6666}{6666}{6666}{6667}; + \__fp_fixed_mul_sub_back:wwwn #4;{10000}{0000}{0000}{0000}{0000}{0000}; + \__fp_fixed_mul:wwn #5; } { \exp_after:wN \__fp_sanitize:Nw - \exp_after:wN #1 - \int_use:N \__int_eval:w \__fp_fixed_to_float:wN + \exp_after:wN #2 + \int_use:N \__int_eval:w #1 } - #1 + #2 } -\cs_new:Npn \__fp_tan_series:NNwww #1#2#3. #4; #5; +\cs_new:Npn \__fp_tan_series_o:NNwww #1#2#3. #4; #5; { \__fp_fixed_mul:wwn #4; #4; { - \exp_after:wN \__fp_tan_series_aux:Nnww + \exp_after:wN \__fp_tan_series_aux_o:Nnww \__int_value:w \if_int_odd:w \__int_eval:w #3 / \c_two \__int_eval_end: \exp_after:wN \reverse_if:N @@ -4071,18 +4124,18 @@ } #4 ; } -\cs_new:Npn \__fp_tan_series_aux:Nnww #1 #2 #3; #4; +\cs_new:Npn \__fp_tan_series_aux_o:Nnww #1 #2 #3; #4; { - \__fp_fixed_continue:wn {0000}{0000}{1527}{3493}{0856}{7059}; - \__fp_fixed_mul_sub_back:wwwn #3; {0000}{0159}{6080}{0274}{5257}{6472}; + \__fp_fixed_mul_sub_back:wwwn {0000}{0000}{1527}{3493}{0856}{7059}; + #3; {0000}{0159}{6080}{0274}{5257}{6472}; \__fp_fixed_mul_sub_back:wwwn #3; {0002}{4571}{2320}{0157}{2558}{8481}; \__fp_fixed_mul_sub_back:wwwn #3; {0115}{5830}{7533}{5397}{3168}{2147}; \__fp_fixed_mul_sub_back:wwwn #3; {1929}{8245}{6140}{3508}{7719}{2982}; \__fp_fixed_mul_sub_back:wwwn #3;{10000}{0000}{0000}{0000}{0000}{0000}; \__fp_fixed_mul:wwn #4; { - \__fp_fixed_continue:wn {0000}{0007}{0258}{0681}{9408}{4706}; - \__fp_fixed_mul_sub_back:wwwn #3; {0000}{2343}{7175}{1399}{6151}{7670}; + \__fp_fixed_mul_sub_back:wwwn {0000}{0007}{0258}{0681}{9408}{4706}; + #3; {0000}{2343}{7175}{1399}{6151}{7670}; \__fp_fixed_mul_sub_back:wwwn #3; {0019}{2638}{4588}{9232}{8861}{3691}; \__fp_fixed_mul_sub_back:wwwn #3; {0536}{6357}{0691}{4344}{6852}{4252}; \__fp_fixed_mul_sub_back:wwwn #3; {5263}{1578}{9473}{6842}{1052}{6315}; @@ -4350,6 +4403,21 @@ \cs_new_eq:NN \fp_eval:n \fp_to_decimal:n \cs_new:Npn \fp_abs:n #1 { \fp_to_decimal:n { abs \__fp_parse:n {#1} } } +\cs_new:Npn \__fp_array_to_clist:n #1 + { + \__fp_array_to_clist_i:wwww ; + #1 + \__fp_array_to_clist_ii:ww \s__fp ; @ + ; , ~ , ~ @ \s_stop + } +\cs_new:Npn \__fp_array_to_clist_i:wwww #1; #2 \s__fp #3; #4 @ + { + #2 + \exp_after:wN \__fp_array_to_clist_i:wwww + \tex_romannumeral:D -`0 \__fp_to_tl:w \s__fp #3 ; ; + #4 , ~ #1 @ + } +\cs_new:Npn \__fp_array_to_clist_ii:ww #1 ; , ~ , ~ #2 @ #3 \s_stop {#2} %% %% File: l3fp-assign.dtx Copyright (C) 2011-2012 The LaTeX3 project %% @@ -4421,7 +4489,14 @@ \cs_generate_variant:Nn \fp_sub:Nn { c } \cs_generate_variant:Nn \fp_gsub:Nn { c } \cs_new_protected:Npn \fp_show:N #1 - { \__msg_show_variable:x { > \fp_to_tl:N #1 } } + { + \fp_if_exist:NTF #1 + { \__msg_show_variable:x { > \fp_to_tl:N #1 } } + { + \__msg_kernel_error:nnx { kernel } { variable-not-defined } + { \token_to_str:N #1 } + } + } \cs_new_protected:Npn \fp_show:n #1 { \__msg_show_variable:x { > \fp_to_tl:n {#1} } } \cs_generate_variant:Nn \fp_show:N { c } |