%%
%% This is file `l3fp.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3fp.dtx  (with options: `package')
%% 
%% EXPERIMENTAL CODE
%% 
%% Do not distribute this file without also distributing the
%% source files specified above.
%% 
%% Do not distribute a modified version of this file.
%% 
%% File: l3fp.dtx Copyright (C) 2010-2012 The LaTeX3 Project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
%% license or (at your option) any later version.  The latest version
%% of this license is in the file
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% This file is part of the "l3kernel bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% The released version of this bundle is available from CTAN.
%%
%% -----------------------------------------------------------------------
%%
%% The development version of the bundle can be found at
%%
%%    http://www.latex-project.org/svnroot/experimental/trunk/
%%
%% for those people who are interested.
%%
%%%%%%%%%%%
%% NOTE: %%
%%%%%%%%%%%
%%
%%   Snapshots taken from the repository represent work in progress and may
%%   not work or may contain conflicting material!  We therefore ask
%%   people _not_ to put them into distributions, archives, etc. without
%%   prior consultation with the LaTeX3 Project.
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
\GetIdInfo$Id: l3fp.dtx 3154 2012-01-08 22:46:28Z bruno $
  {L3 Experimental floating-point operations}
\ProvidesExplPackage
  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\package_check_loaded_expl:
\int_const:Nn \c_forty_four { 44 }
\int_const:Nn \c_one_million { 1 000 000 }
\int_const:Nn \c_one_hundred_million { 100 000 000 }
\int_const:Nn \c_five_hundred_million { 500 000 000 }
\int_const:Nn \c_one_thousand_million { 1 000 000 000 }
\int_new:N  \c_fp_pi_by_four_decimal_int
\int_set:Nn \c_fp_pi_by_four_decimal_int { 785 398 158 }
\int_new:N  \c_fp_pi_by_four_extended_int
\int_set:Nn \c_fp_pi_by_four_extended_int { 897 448 310 }
\int_new:N  \c_fp_pi_decimal_int
\int_set:Nn \c_fp_pi_decimal_int { 141 592 653 }
\int_new:N  \c_fp_pi_extended_int
\int_set:Nn \c_fp_pi_extended_int { 589 793 238 }
\int_new:N  \c_fp_two_pi_decimal_int
\int_set:Nn \c_fp_two_pi_decimal_int { 283 185 307 }
\int_new:N  \c_fp_two_pi_extended_int
\int_set:Nn \c_fp_two_pi_extended_int { 179 586 477 }
\tl_const:Nn \c_e_fp { + 2.718281828 e 0 }
\tl_const:Nn \c_one_fp { + 1.000000000 e 0 }
\tl_const:Nn \c_pi_fp { + 3.141592654 e 0 }
\tl_const:Nn \c_undefined_fp { X 0.000000000 e 0 }
\tl_const:Nn \c_zero_fp { + 0.000000000 e 0 }
\tl_new:N \l_fp_arg_tl
\int_new:N \l_fp_count_int
\int_new:N \l_fp_div_offset_int
\int_new:N \l_fp_exp_integer_int
\int_new:N \l_fp_exp_decimal_int
\int_new:N \l_fp_exp_extended_int
\int_new:N \l_fp_exp_exponent_int
\int_new:N \l_fp_input_a_sign_int
\int_new:N \l_fp_input_a_integer_int
\int_new:N \l_fp_input_a_decimal_int
\int_new:N \l_fp_input_a_exponent_int
\int_new:N \l_fp_input_b_sign_int
\int_new:N \l_fp_input_b_integer_int
\int_new:N \l_fp_input_b_decimal_int
\int_new:N \l_fp_input_b_exponent_int
\int_new:N \l_fp_input_a_extended_int
\int_new:N \l_fp_input_b_extended_int
\int_new:N \l_fp_mul_a_i_int
\int_new:N \l_fp_mul_a_ii_int
\int_new:N \l_fp_mul_a_iii_int
\int_new:N \l_fp_mul_a_iv_int
\int_new:N \l_fp_mul_a_v_int
\int_new:N \l_fp_mul_a_vi_int
\int_new:N \l_fp_mul_b_i_int
\int_new:N \l_fp_mul_b_ii_int
\int_new:N \l_fp_mul_b_iii_int
\int_new:N \l_fp_mul_b_iv_int
\int_new:N \l_fp_mul_b_v_int
\int_new:N \l_fp_mul_b_vi_int
\int_new:N \l_fp_mul_output_int
\tl_new:N  \l_fp_mul_output_tl
\int_new:N \l_fp_output_sign_int
\int_new:N \l_fp_output_integer_int
\int_new:N \l_fp_output_decimal_int
\int_new:N \l_fp_output_exponent_int
\int_new:N \l_fp_output_extended_int
\bool_new:N \l_fp_round_carry_bool
\tl_new:N \l_fp_round_decimal_tl
\int_new:N \l_fp_round_position_int
\int_new:N \l_fp_round_target_int
\tl_new:N \l_fp_sign_tl
\int_new:N \l_fp_split_sign_int
\int_new:N \l_fp_internal_int
\tl_new:N \l_fp_internal_tl
\int_new:N \l_fp_trig_octant_int
\int_new:N \l_fp_trig_sign_int
\int_new:N \l_fp_trig_decimal_int
\int_new:N \l_fp_trig_extended_int
\cs_new_protected:Npn \fp_read:N #1
  { \exp_after:wN \fp_read_aux:w #1 \q_stop }
\cs_new_protected:Npn \fp_read_aux:w #1#2 . #3 e #4 \q_stop
  {
    \if:w #1 -
      \l_fp_input_a_sign_int \c_minus_one
    \else:
      \l_fp_input_a_sign_int \c_one
    \fi:
    \l_fp_input_a_integer_int  #2 \scan_stop:
    \l_fp_input_a_decimal_int  #3 \scan_stop:
    \l_fp_input_a_exponent_int #4 \scan_stop:
  }
\cs_new_protected:Npn \fp_split:Nn #1#2
  {
    \tl_set:Nx \l_fp_internal_tl {#2}
    \tl_set_rescan:Nno \l_fp_internal_tl { \char_set_catcode_ignore:n { 32 } }
      { \l_fp_internal_tl }
    \l_fp_split_sign_int \c_one
    \fp_split_sign:
    \use:c { l_fp_input_ #1 _sign_int } \l_fp_split_sign_int
    \exp_after:wN \fp_split_exponent:w \l_fp_internal_tl e e \q_stop #1
  }
\cs_new_protected_nopar:Npn \fp_split_sign:
  {
    \if_int_compare:w \pdftex_strcmp:D
      { \exp_after:wN \tl_head:w \l_fp_internal_tl ? \q_stop } { - }
        = \c_zero
      \tl_set:Nx \l_fp_internal_tl
        {
          \exp_after:wN
            \tl_tail:w \l_fp_internal_tl \prg_do_nothing: \q_stop
        }
      \l_fp_split_sign_int -\l_fp_split_sign_int
      \exp_after:wN \fp_split_sign:
    \else:
      \if_int_compare:w \pdftex_strcmp:D
        { \exp_after:wN \tl_head:w \l_fp_internal_tl ? \q_stop } { + }
          = \c_zero
        \tl_set:Nx \l_fp_internal_tl
          {
            \exp_after:wN
              \tl_tail:w \l_fp_internal_tl \prg_do_nothing: \q_stop
          }
        \exp_after:wN \exp_after:wN \exp_after:wN \fp_split_sign:
       \fi:
    \fi:
  }
\cs_new_protected:Npn \fp_split_exponent:w #1 e #2 e #3 \q_stop #4
  {
    \use:c { l_fp_input_ #4 _exponent_int }
      \int_eval:w 0 #2 \scan_stop:
    \tex_afterassignment:D \fp_split_aux_i:w
    \use:c { l_fp_input_ #4 _integer_int }
      \int_eval:w 0 #1 . . \q_stop #4
  }
\cs_new_protected:Npn \fp_split_aux_i:w #1 . #2 . #3 \q_stop
  { \fp_split_aux_ii:w #2 000000000 \q_stop }
\cs_new_protected:Npn \fp_split_aux_ii:w #1#2#3#4#5#6#7#8#9
  { \fp_split_aux_iii:w {#1#2#3#4#5#6#7#8#9} }
\cs_new_protected:Npn \fp_split_aux_iii:w #1#2 \q_stop
  {
    \l_fp_internal_int 1 #1 \scan_stop:
    \exp_after:wN \fp_split_decimal:w
      \int_use:N \l_fp_internal_int 000000000 \q_stop
  }
\cs_new_protected:Npn \fp_split_decimal:w #1#2#3#4#5#6#7#8#9
  { \fp_split_decimal_aux:w {#2#3#4#5#6#7#8#9} }
\cs_new_protected:Npn \fp_split_decimal_aux:w #1#2#3 \q_stop #4
  {
    \use:c { l_fp_input_ #4 _decimal_int } #1#2 \scan_stop:
    \if_int_compare:w
      \int_eval:w
        \use:c { l_fp_input_ #4 _integer_int } +
        \use:c { l_fp_input_ #4 _decimal_int }
      \scan_stop:
        = \c_zero
      \use:c { l_fp_input_ #4 _sign_int } \c_one
    \fi:
    \if_int_compare:w
      \use:c { l_fp_input_ #4 _integer_int } < \c_one_thousand_million
    \else:
      \exp_after:wN \fp_overflow_msg:
    \fi:
  }
\cs_new_protected:Npn \fp_standardise:NNNN #1#2#3#4
  {
    \if_int_compare:w
      \int_eval:w #2 + #3 = \c_zero
      #1 \c_one
      #4 \c_zero
      \exp_after:wN \use_none:nnnn
    \else:
      \exp_after:wN \fp_standardise_aux:NNNN
    \fi:
    #1#2#3#4
  }
\cs_new_protected:Npn \fp_standardise_aux:NNNN #1#2#3#4
  {
    \cs_set_protected_nopar:Npn \fp_standardise_aux:
      {
        \if_int_compare:w #2 = \c_zero
          \tex_advance:D #3 \c_one_thousand_million
          \exp_after:wN \fp_standardise_aux:w
            \int_use:N #3 \q_stop
           \exp_after:wN \fp_standardise_aux:
         \fi:
      }
    \cs_set_protected:Npn
      \fp_standardise_aux:w ##1##2##3##4##5##6##7##8##9 \q_stop
      {
        #2 ##2 \scan_stop:
        #3 ##3##4##5##6##7##8##9 0 \scan_stop:
        \tex_advance:D #4 \c_minus_one
      }
    \fp_standardise_aux:
    \cs_set_protected_nopar:Npn \fp_standardise_aux:
      {
        \if_int_compare:w #2 > \c_nine
          \tex_advance:D #2 \c_one_thousand_million
          \exp_after:wN \use_i:nn \exp_after:wN
            \fp_standardise_aux:w \int_use:N #2
           \exp_after:wN \fp_standardise_aux:
         \fi:
      }
    \cs_set_protected:Npn
      \fp_standardise_aux:w ##1##2##3##4##5##6##7##8##9
      {
        #2 ##1##2##3##4##5##6##7##8 \scan_stop:
        \tex_advance:D #3 \c_one_thousand_million
        \tex_divide:D #3 \c_ten
        \tl_set:Nx \l_fp_internal_tl
          {
            ##9
            \exp_after:wN \use_none:n \int_use:N #3
          }
        #3 \l_fp_internal_tl \scan_stop:
        \tex_advance:D #4 \c_one
      }
    \fp_standardise_aux:
    \if_int_compare:w #4 < \c_one_hundred
      \if_int_compare:w #4 > -\c_one_hundred
      \else:
        #1 \c_one
        #2 \c_zero
        #3 \c_zero
        #4 \c_zero
      \fi:
    \else:
      \exp_after:wN \fp_overflow_msg:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_standardise_aux: { }
\cs_new_protected_nopar:Npn \fp_standardise_aux:w { }
\cs_new_protected_nopar:Npn \fp_level_input_exponents:
  {
    \if_int_compare:w \l_fp_input_a_exponent_int > \l_fp_input_b_exponent_int
      \exp_after:wN \fp_level_input_exponents_a:
    \else:
      \exp_after:wN \fp_level_input_exponents_b:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_level_input_exponents_a:
  {
    \if_int_compare:w \l_fp_input_a_exponent_int > \l_fp_input_b_exponent_int
      \tex_advance:D \l_fp_input_b_integer_int \c_one_thousand_million
      \exp_after:wN \use_i:nn \exp_after:wN
        \fp_level_input_exponents_a:NNNNNNNNN
          \int_use:N \l_fp_input_b_integer_int
      \exp_after:wN \fp_level_input_exponents_a:
    \fi:
  }
\cs_new_protected:Npn \fp_level_input_exponents_a:NNNNNNNNN
  #1#2#3#4#5#6#7#8#9
  {
    \l_fp_input_b_integer_int #1#2#3#4#5#6#7#8 \scan_stop:
    \tex_advance:D \l_fp_input_b_decimal_int \c_one_thousand_million
    \tex_divide:D \l_fp_input_b_decimal_int \c_ten
    \tl_set:Nx \l_fp_internal_tl
      {
        #9
        \exp_after:wN \use_none:n
          \int_use:N \l_fp_input_b_decimal_int
      }
    \l_fp_input_b_decimal_int \l_fp_internal_tl \scan_stop:
    \tex_advance:D \l_fp_input_b_exponent_int \c_one
  }
\cs_new_protected_nopar:Npn \fp_level_input_exponents_b:
  {
    \if_int_compare:w \l_fp_input_b_exponent_int > \l_fp_input_a_exponent_int
      \tex_advance:D \l_fp_input_a_integer_int \c_one_thousand_million
      \exp_after:wN \use_i:nn \exp_after:wN
        \fp_level_input_exponents_b:NNNNNNNNN
          \int_use:N \l_fp_input_a_integer_int
      \exp_after:wN \fp_level_input_exponents_b:
    \fi:
  }
\cs_new_protected:Npn \fp_level_input_exponents_b:NNNNNNNNN
  #1#2#3#4#5#6#7#8#9
  {
    \l_fp_input_a_integer_int #1#2#3#4#5#6#7#8 \scan_stop:
    \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
    \tex_divide:D \l_fp_input_a_decimal_int \c_ten
    \tl_set:Nx \l_fp_internal_tl
      {
        #9
        \exp_after:wN \use_none:n
          \int_use:N \l_fp_input_a_decimal_int
      }
    \l_fp_input_a_decimal_int \l_fp_internal_tl \scan_stop:
    \tex_advance:D \l_fp_input_a_exponent_int \c_one
  }
\cs_new_protected:Npn \fp_tmp:w #1#2 { }
\cs_new_protected:Npn \fp_new:N #1
  {
    \tl_new:N #1
    \tl_gset_eq:NN #1 \c_zero_fp
  }
\cs_generate_variant:Nn \fp_new:N { c }
\cs_new_protected:Npn \fp_const:Nn #1#2
  {
    \fp_new:N #1
    \fp_gset:Nn #1 {#2}
  }
\cs_generate_variant:Nn \fp_const:Nn { c }
\cs_new_protected:Npn \fp_zero:N #1
  { \tl_set_eq:NN #1 \c_zero_fp }
\cs_new_protected:Npn \fp_gzero:N #1
  { \tl_gset_eq:NN #1 \c_zero_fp }
\cs_generate_variant:Nn \fp_zero:N { c }
\cs_generate_variant:Nn \fp_gzero:N { c }
\cs_new_protected:Npn \fp_zero_new:N  #1
  { \cs_if_exist:NTF #1 { \fp_zero:N #1 } { \fp_new:N #1 } }
\cs_new_protected:Npn \fp_gzero_new:N #1
  { \cs_if_exist:NTF #1 { \fp_gzero:N #1 } { \fp_new:N #1 } }
\cs_generate_variant:Nn \fp_zero_new:N  { c }
\cs_generate_variant:Nn \fp_gzero_new:N { c }
\cs_new_protected_nopar:Npn \fp_set:Nn  { \fp_set_aux:NNn \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gset:Nn { \fp_set_aux:NNn \tl_gset:Nn }
\cs_new_protected:Npn \fp_set_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_split:Nn a {#3}
      \fp_standardise:NNNN
        \l_fp_input_a_sign_int
        \l_fp_input_a_integer_int
        \l_fp_input_a_decimal_int
        \l_fp_input_a_exponent_int
      \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
      \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          #1 \exp_not:N #2
            {
              \if_int_compare:w \l_fp_input_a_sign_int < \c_zero
                -
              \else:
                +
              \fi:
              \int_use:N \l_fp_input_a_integer_int
              .
              \exp_after:wN \use_none:n
                \int_use:N \l_fp_input_a_decimal_int
              e
              \int_use:N \l_fp_input_a_exponent_int
            }
        }
    \fp_tmp:w
  }
\cs_generate_variant:Nn \fp_set:Nn  { c }
\cs_generate_variant:Nn \fp_gset:Nn { c }
\cs_new_protected_nopar:Npn \fp_set_from_dim:Nn
  { \fp_set_from_dim_aux:NNn \tl_set:Nx }
\cs_new_protected_nopar:Npn \fp_gset_from_dim:Nn
  { \fp_set_from_dim_aux:NNn \tl_gset:Nx }
\cs_new_protected:Npn \fp_set_from_dim_aux:NNn #1#2#3
  {
    \group_begin:
      \l_fp_internal_skip \etex_glueexpr:D #3 \scan_stop:
      \l_fp_internal_dim \l_fp_internal_skip
      \fp_split:Nn a
        {
          \exp_after:wN \fp_set_from_dim_aux:w
            \dim_use:N \l_fp_internal_dim
        }
      \fp_standardise:NNNN
        \l_fp_input_a_sign_int
        \l_fp_input_a_integer_int
        \l_fp_input_a_decimal_int
        \l_fp_input_a_exponent_int
      \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
      \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          #1 \exp_not:N #2
            {
              \if_int_compare:w \l_fp_input_a_sign_int < \c_zero
                -
              \else:
                +
              \fi:
              \int_use:N \l_fp_input_a_integer_int
              .
              \exp_after:wN \use_none:n
                \int_use:N \l_fp_input_a_decimal_int
              e
              \int_use:N \l_fp_input_a_exponent_int
            }
        }
    \fp_tmp:w
  }
\cs_set_protected_nopar:Npx \fp_set_from_dim_aux:w
  {
    \cs_set:Npn \exp_not:N \fp_set_from_dim_aux:w
      ##1 \tl_to_str:n { pt } {##1}
  }
\fp_set_from_dim_aux:w
\cs_generate_variant:Nn \fp_set_from_dim:Nn  { c }
\cs_generate_variant:Nn \fp_gset_from_dim:Nn { c }
\dim_new:N \l_fp_internal_dim
\skip_new:N \l_fp_internal_skip
\cs_new_eq:NN \fp_set_eq:NN  \tl_set_eq:NN
\cs_new_eq:NN \fp_set_eq:cN  \tl_set_eq:cN
\cs_new_eq:NN \fp_set_eq:Nc  \tl_set_eq:Nc
\cs_new_eq:NN \fp_set_eq:cc  \tl_set_eq:cc
\cs_new_eq:NN \fp_gset_eq:NN \tl_gset_eq:NN
\cs_new_eq:NN \fp_gset_eq:cN \tl_gset_eq:cN
\cs_new_eq:NN \fp_gset_eq:Nc \tl_gset_eq:Nc
\cs_new_eq:NN \fp_gset_eq:cc \tl_gset_eq:cc
\cs_new_eq:NN \fp_show:N \tl_show:N
\cs_new_eq:NN \fp_show:c \tl_show:c
\cs_new:Npn \fp_use:N #1
  { \exp_after:wN \fp_use_aux:w #1 \q_stop }
\cs_generate_variant:Nn \fp_use:N { c }
\cs_new:Npn \fp_use_aux:w #1#2 e #3 \q_stop
  {
    \if:w #1 -
      -
    \fi:
    \if_int_compare:w #3 > \c_zero
      \exp_after:wN \fp_use_large:w
    \else:
      \if_int_compare:w #3 < \c_zero
        \exp_after:wN \exp_after:wN \exp_after:wN
          \fp_use_small:w
      \else:
        \exp_after:wN \exp_after:wN \exp_after:wN \fp_use_none:w
      \fi:
    \fi:
    #2 e #3 \q_stop
  }
\cs_new:Npn \fp_use_none:w #1 e #2 \q_stop {#1}
\cs_new:Npn \fp_use_small:w #1 . #2 e #3 \q_stop
  {
    0 .
    \prg_replicate:nn { -#3 - 1 } { 0 }
    #1#2
  }
\cs_new:Npn \fp_use_large:w #1 . #2 e #3 \q_stop
  {
    \if_int_compare:w #3 < \c_ten
      \exp_after:wN \fp_use_large_aux_i:w
    \else:
      \exp_after:wN \fp_use_large_aux_ii:w
    \fi:
    #1#2 e #3 \q_stop
  }
\cs_new:Npn \fp_use_large_aux_i:w #1#2 e #3 \q_stop
  {
    #1
    \use:c { fp_use_large_aux_ #3 :w } #2 \q_stop
  }
\cs_new:cpn { fp_use_large_aux_1:w } #1#2 \q_stop { #1 . #2 }
\cs_new:cpn { fp_use_large_aux_2:w } #1#2#3 \q_stop
  { #1#2 . #3 }
\cs_new:cpn { fp_use_large_aux_3:w } #1#2#3#4 \q_stop
  { #1#2#3 . #4 }
\cs_new:cpn { fp_use_large_aux_4:w } #1#2#3#4#5 \q_stop
  { #1#2#3#4 . #5 }
\cs_new:cpn { fp_use_large_aux_5:w } #1#2#3#4#5#6 \q_stop
  { #1#2#3#4#5 . #6 }
\cs_new:cpn { fp_use_large_aux_6:w } #1#2#3#4#5#6#7 \q_stop
  { #1#2#3#4#5#6 . #7 }
\cs_new:cpn { fp_use_large_aux_7:w } #1#2#3#4#5#6#7#8 \q_stop
  { #1#2#3#4#6#7 . #8 }
\cs_new:cpn { fp_use_large_aux_8:w } #1#2#3#4#5#6#7#8#9 \q_stop
  { #1#2#3#4#5#6#7#8 . #9 }
\cs_new:cpn { fp_use_large_aux_9:w } #1 \q_stop { #1 . }
\cs_new:Npn \fp_use_large_aux_ii:w #1 e #2 \q_stop
  {
    #1
    \prg_replicate:nn { #2 - 9 } { 0 }
    .
  }
\cs_new:Npn \fp_to_dim:N #1 { \fp_use:N #1 pt }
\cs_generate_variant:Nn \fp_to_dim:N { c }
\cs_new:Npn \fp_to_int:N #1
  { \exp_after:wN \fp_to_int_aux:w #1 \q_stop }
\cs_generate_variant:Nn \fp_to_int:N { c }
\cs_new:Npn \fp_to_int_aux:w #1#2 e #3 \q_stop
  {
    \if:w #1 -
      -
    \fi:
    \if_int_compare:w #3 < \c_zero
      \exp_after:wN \fp_to_int_small:w
    \else:
      \exp_after:wN \fp_to_int_large:w
    \fi:
    #2 e #3 \q_stop
  }
\cs_new:Npn \fp_to_int_small:w #1 . #2 e #3 \q_stop
  {
    \if_int_compare:w #3 > \c_one
    \else:
      \if_int_compare:w #1 < \c_five
        0
      \else:
        1
      \fi:
    \fi:
  }
\cs_new:Npn \fp_to_int_large:w #1 . #2 e #3 \q_stop
  {
    \if_int_compare:w #3 < \c_ten
      \exp_after:wN \fp_to_int_large_aux_i:w
    \else:
      \exp_after:wN \fp_to_int_large_aux_ii:w
    \fi:
    #1#2 e #3 \q_stop
  }
\cs_new:Npn \fp_to_int_large_aux_i:w #1#2 e #3 \q_stop
  { \use:c { fp_to_int_large_aux_ #3 :w } #2 \q_stop {#1} }
\cs_new:cpn { fp_to_int_large_aux_1:w } #1#2 \q_stop
  { \fp_to_int_large_aux:nnn { #2 0 } {#1} }
\cs_new:cpn { fp_to_int_large_aux_2:w } #1#2#3 \q_stop
  { \fp_to_int_large_aux:nnn { #3 00 } {#1#2} }
\cs_new:cpn { fp_to_int_large_aux_3:w } #1#2#3#4 \q_stop
  { \fp_to_int_large_aux:nnn { #4 000 } {#1#2#3} }
\cs_new:cpn { fp_to_int_large_aux_4:w } #1#2#3#4#5 \q_stop
  { \fp_to_int_large_aux:nnn { #5 0000 } {#1#2#3#4} }
\cs_new:cpn { fp_to_int_large_aux_5:w } #1#2#3#4#5#6 \q_stop
  { \fp_to_int_large_aux:nnn { #6 00000 } {#1#2#3#4#5} }
\cs_new:cpn { fp_to_int_large_aux_6:w } #1#2#3#4#5#6#7 \q_stop
  { \fp_to_int_large_aux:nnn { #7 000000 } {#1#2#3#4#5#6} }
\cs_new:cpn { fp_to_int_large_aux_7:w } #1#2#3#4#5#6#7#8 \q_stop
  { \fp_to_int_large_aux:nnn { #8 0000000 } {#1#2#3#4#5#6#7} }
\cs_new:cpn { fp_to_int_large_aux_8:w } #1#2#3#4#5#6#7#8#9 \q_stop
  { \fp_to_int_large_aux:nnn { #9 00000000 } {#1#2#3#4#5#6#7#8} }
\cs_new:cpn { fp_to_int_large_aux_9:w } #1 \q_stop {#1}
\cs_new:Npn \fp_to_int_large_aux:nnn #1#2#3
  {
    \if_int_compare:w #1 < \c_five_hundred_million
      #3#2
    \else:
      \int_value:w \int_eval:w #3#2 + 1 \int_eval_end:
    \fi:
  }
\cs_new:Npn \fp_to_int_large_aux_ii:w #1 e #2 \q_stop
  {
    #1
    \prg_replicate:nn { #2 - 9 } { 0 }
  }
\cs_new:Npn \fp_to_tl:N #1
  { \exp_after:wN \fp_to_tl_aux:w #1 \q_stop }
\cs_generate_variant:Nn \fp_to_tl:N { c }
\cs_new:Npn \fp_to_tl_aux:w #1#2 e #3 \q_stop
  {
    \if:w #1 -
      -
    \fi:
    \if_int_compare:w #3 < \c_zero
      \exp_after:wN \fp_to_tl_small:w
    \else:
      \exp_after:wN \fp_to_tl_large:w
    \fi:
    #2 e #3 \q_stop
  }
\cs_new:Npn \fp_to_tl_large:w #1 e #2 \q_stop
  {
    \if_int_compare:w #2 < \c_ten
      \exp_after:wN \fp_to_tl_large_aux_i:w
    \else:
      \exp_after:wN \fp_to_tl_large_aux_ii:w
    \fi:
    #1 e #2 \q_stop
  }
\cs_new:Npn \fp_to_tl_large_aux_i:w #1 e #2 \q_stop
  { \use:c { fp_to_tl_large_ #2 :w } #1 \q_stop }
\cs_new:Npn \fp_to_tl_large_aux_ii:w #1 . #2 e #3 \q_stop
  {
    #1
    \fp_to_tl_large_zeros:NNNNNNNNN #2
    e #3
  }
\cs_new:cpn { fp_to_tl_large_0:w } #1 . #2 \q_stop
  {
    #1
    \fp_to_tl_large_zeros:NNNNNNNNN #2
  }
\cs_new:cpn { fp_to_tl_large_1:w } #1 . #2#3 \q_stop
  {
    #1#2
    \fp_to_tl_large_zeros:NNNNNNNNN #3 0
  }
\cs_new:cpn { fp_to_tl_large_2:w } #1 . #2#3#4 \q_stop
  {
    #1#2#3
    \fp_to_tl_large_zeros:NNNNNNNNN #4 00
  }
\cs_new:cpn { fp_to_tl_large_3:w } #1 . #2#3#4#5 \q_stop
  {
    #1#2#3#4
    \fp_to_tl_large_zeros:NNNNNNNNN #5 000
  }
\cs_new:cpn { fp_to_tl_large_4:w } #1 . #2#3#4#5#6 \q_stop
  {
    #1#2#3#4#5
    \fp_to_tl_large_zeros:NNNNNNNNN #6 0000
  }
\cs_new:cpn { fp_to_tl_large_5:w } #1 . #2#3#4#5#6#7 \q_stop
  {
    #1#2#3#4#5#6
    \fp_to_tl_large_zeros:NNNNNNNNN #7 00000
  }
\cs_new:cpn { fp_to_tl_large_6:w } #1 . #2#3#4#5#6#7#8 \q_stop
  {
    #1#2#3#4#5#6#7
    \fp_to_tl_large_zeros:NNNNNNNNN #8 000000
  }
\cs_new:cpn { fp_to_tl_large_7:w } #1 . #2#3#4#5#6#7#8#9 \q_stop
  {
    #1#2#3#4#5#6#7#8
    \fp_to_tl_large_zeros:NNNNNNNNN #9 0000000
  }
\cs_new:cpn { fp_to_tl_large_8:w } #1 .
  {
    #1
    \use:c { fp_to_tl_large_8_aux:w }
  }
\cs_new:cpn { fp_to_tl_large_8_aux:w } #1#2#3#4#5#6#7#8#9 \q_stop
  {
    #1#2#3#4#5#6#7#8
    \fp_to_tl_large_zeros:NNNNNNNNN #9 00000000
  }
\cs_new:cpn { fp_to_tl_large_9:w } #1 . #2 \q_stop {#1#2}
\cs_new:Npn \fp_to_tl_small:w #1 e #2 \q_stop
  {
    \if_int_compare:w #2 = \c_minus_one
      \exp_after:wN \fp_to_tl_small_one:w
    \else:
      \if_int_compare:w #2 = -\c_two
        \exp_after:wN \exp_after:wN \exp_after:wN \fp_to_tl_small_two:w
      \else:
        \exp_after:wN \exp_after:wN \exp_after:wN \fp_to_tl_small_aux:w
      \fi:
    \fi:
    #1 e #2 \q_stop
  }
\cs_new:Npn \fp_to_tl_small_one:w #1 . #2 e #3 \q_stop
  {
    \if_int_compare:w \fp_use_ix:NNNNNNNNN #2 > \c_four
      \if_int_compare:w
        \int_eval:w #1 \fp_use_i_to_iix:NNNNNNNNN #2 + 1
          < \c_one_thousand_million
        0.
        \exp_after:wN \fp_to_tl_small_zeros:NNNNNNNNN
          \int_value:w \int_eval:w
              #1 \fp_use_i_to_iix:NNNNNNNNN #2 + 1
            \int_eval_end:
      \else:
        1
      \fi:
    \else:
      0. #1
      \fp_to_tl_small_zeros:NNNNNNNNN #2
    \fi:
  }
\cs_new:Npn \fp_to_tl_small_two:w #1 . #2 e #3 \q_stop
  {
    \if_int_compare:w \fp_use_iix_ix:NNNNNNNNN #2 > \c_forty_four
      \if_int_compare:w
        \int_eval:w #1 \fp_use_i_to_vii:NNNNNNNNN #2 0 + \c_ten
          < \c_one_thousand_million
        0.0
        \exp_after:wN \fp_to_tl_small_zeros:NNNNNNNNN
          \int_value:w \int_eval:w
              #1 \fp_use_i_to_vii:NNNNNNNNN #2 0 + \c_ten
            \int_eval_end:
      \else:
        0.1
      \fi:
    \else:
      0.0
      #1
      \fp_to_tl_small_zeros:NNNNNNNNN #2
    \fi:
  }
\cs_new:Npn \fp_to_tl_small_aux:w #1 . #2 e #3 \q_stop
  {
    #1
    \fp_to_tl_large_zeros:NNNNNNNNN #2
    e #3
  }
\cs_new:Npn \fp_to_tl_large_zeros:NNNNNNNNN #1#2#3#4#5#6#7#8#9
  {
    \if_int_compare:w #9 = \c_zero
      \if_int_compare:w #8 = \c_zero
        \if_int_compare:w #7 = \c_zero
          \if_int_compare:w #6 = \c_zero
            \if_int_compare:w #5 = \c_zero
              \if_int_compare:w #4 = \c_zero
                \if_int_compare:w #3 = \c_zero
                  \if_int_compare:w #2 = \c_zero
                    \if_int_compare:w #1 = \c_zero
                    \else:
                      . #1
                    \fi:
                  \else:
                    . #1#2
                  \fi:
                \else:
                  . #1#2#3
                \fi:
              \else:
                . #1#2#3#4
              \fi:
            \else:
              . #1#2#3#4#5
            \fi:
          \else:
            . #1#2#3#4#5#6
          \fi:
        \else:
          . #1#2#3#4#5#6#7
        \fi:
      \else:
         . #1#2#3#4#5#6#7#8
      \fi:
    \else:
      . #1#2#3#4#5#6#7#8#9
    \fi:
  }
\cs_new:Npn \fp_to_tl_small_zeros:NNNNNNNNN #1#2#3#4#5#6#7#8#9
  {
    \if_int_compare:w #9 = \c_zero
      \if_int_compare:w #8 = \c_zero
        \if_int_compare:w #7 = \c_zero
          \if_int_compare:w #6 = \c_zero
            \if_int_compare:w #5 = \c_zero
              \if_int_compare:w #4 = \c_zero
                \if_int_compare:w #3 = \c_zero
                  \if_int_compare:w #2 = \c_zero
                    \if_int_compare:w #1 = \c_zero
                    \else:
                      #1
                    \fi:
                  \else:
                    #1#2
                  \fi:
                \else:
                  #1#2#3
                \fi:
              \else:
                #1#2#3#4
              \fi:
            \else:
              #1#2#3#4#5
            \fi:
          \else:
            #1#2#3#4#5#6
          \fi:
        \else:
          #1#2#3#4#5#6#7
        \fi:
      \else:
         #1#2#3#4#5#6#7#8
      \fi:
    \else:
      #1#2#3#4#5#6#7#8#9
    \fi:
  }
\cs_new:Npn \fp_use_iix_ix:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {#8#9}
\cs_new:Npn \fp_use_ix:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {#9}
\cs_new:Npn \fp_use_i_to_vii:NNNNNNNNN #1#2#3#4#5#6#7#8#9
  {#1#2#3#4#5#6#7}
\cs_new:Npn \fp_use_i_to_iix:NNNNNNNNN #1#2#3#4#5#6#7#8#9
  {#1#2#3#4#5#6#7#8}
\cs_new_protected_nopar:Npn \fp_round_figures:Nn
  { \fp_round_figures_aux:NNn \tl_set:Nn }
\cs_generate_variant:Nn \fp_round_figures:Nn { c }
\cs_new_protected_nopar:Npn \fp_ground_figures:Nn
  { \fp_round_figures_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_ground_figures:Nn { c }
\cs_new_protected:Npn \fp_round_figures_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_read:N #2
      \int_set:Nn \l_fp_round_target_int { #3 - 1 }
      \if_int_compare:w \l_fp_round_target_int < \c_ten
        \exp_after:wN \fp_round:
      \fi:
      \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
      \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          #1 \exp_not:N #2
            {
              \if_int_compare:w \l_fp_input_a_sign_int < \c_zero
                -
              \else:
                +
              \fi:
              \int_use:N \l_fp_input_a_integer_int
              .
              \exp_after:wN \use_none:n
                \int_use:N \l_fp_input_a_decimal_int
              e
              \int_use:N \l_fp_input_a_exponent_int
            }
        }
    \fp_tmp:w
  }
\cs_new_protected_nopar:Npn \fp_round_places:Nn
  { \fp_round_places_aux:NNn \tl_set:Nn }
\cs_generate_variant:Nn \fp_round_places:Nn { c }
\cs_new_protected_nopar:Npn \fp_ground_places:Nn
  { \fp_round_places_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_ground_places:Nn { c }
\cs_new_protected:Npn \fp_round_places_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_read:N #2
      \int_set:Nn \l_fp_round_target_int
        { #3 + \l_fp_input_a_exponent_int }
      \if_int_compare:w \l_fp_round_target_int < \c_ten
        \exp_after:wN \fp_round:
      \fi:
      \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
      \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          #1 \exp_not:N #2
            {
              \if_int_compare:w \l_fp_input_a_sign_int < \c_zero
                -
              \else:
                +
              \fi:
              \int_use:N \l_fp_input_a_integer_int
              .
              \exp_after:wN \use_none:n
                \int_use:N \l_fp_input_a_decimal_int
              e
              \int_use:N \l_fp_input_a_exponent_int
            }
        }
    \fp_tmp:w
  }
\cs_new_protected_nopar:Npn \fp_round:
  {
    \bool_set_false:N \l_fp_round_carry_bool
    \l_fp_round_position_int \c_eight
    \tl_clear:N \l_fp_round_decimal_tl
    \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
    \exp_after:wN \use_i:nn \exp_after:wN
      \fp_round_aux:NNNNNNNNN \int_use:N \l_fp_input_a_decimal_int
  }
\cs_new_protected:Npn \fp_round_aux:NNNNNNNNN #1#2#3#4#5#6#7#8#9
  {
    \fp_round_loop:N #9#8#7#6#5#4#3#2#1
    \bool_if:NT \l_fp_round_carry_bool
      { \tex_advance:D \l_fp_input_a_integer_int \c_one }
    \l_fp_input_a_decimal_int \l_fp_round_decimal_tl \scan_stop:
    \if_int_compare:w \l_fp_input_a_integer_int < \c_ten
    \else:
      \l_fp_input_a_integer_int \c_one
      \tex_divide:D \l_fp_input_a_decimal_int \c_ten
      \tex_advance:D \l_fp_input_a_exponent_int \c_one
    \fi:
  }
\cs_new_protected:Npn \fp_round_loop:N #1
  {
    \if_int_compare:w \l_fp_round_position_int < \l_fp_round_target_int
      \bool_if:NTF \l_fp_round_carry_bool
        { \l_fp_internal_int \int_eval:w #1 + \c_one \scan_stop: }
        { \l_fp_internal_int \int_eval:w #1 \scan_stop: }
      \if_int_compare:w \l_fp_internal_int = \c_ten
        \l_fp_internal_int \c_zero
      \else:
        \bool_set_false:N \l_fp_round_carry_bool
      \fi:
      \tl_set:Nx \l_fp_round_decimal_tl
        { \int_use:N \l_fp_internal_int \l_fp_round_decimal_tl }
    \else:
      \tl_set:Nx \l_fp_round_decimal_tl { 0 \l_fp_round_decimal_tl }
      \if_int_compare:w \l_fp_round_position_int = \l_fp_round_target_int
        \if_int_compare:w #1 > \c_four
          \bool_set_true:N \l_fp_round_carry_bool
        \fi:
      \fi:
    \fi:
    \tex_advance:D \l_fp_round_position_int \c_minus_one
    \if_int_compare:w \l_fp_round_position_int > \c_minus_one
      \exp_after:wN \fp_round_loop:N
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_abs:N  { \fp_abs_aux:NN \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gabs:N { \fp_abs_aux:NN \tl_gset:Nn }
\cs_generate_variant:Nn \fp_abs:N  { c }
\cs_generate_variant:Nn \fp_gabs:N { c }
\cs_new_protected:Npn \fp_abs_aux:NN #1#2
  {
    \group_begin:
      \fp_read:N #2
      \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
      \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          #1 \exp_not:N #2
            {
              +
              \int_use:N \l_fp_input_a_integer_int
              .
              \exp_after:wN \use_none:n
                \int_use:N \l_fp_input_a_decimal_int
              e
              \int_use:N \l_fp_input_a_exponent_int
            }
        }
    \fp_tmp:w
  }
\cs_new_protected_nopar:Npn \fp_neg:N  { \fp_neg_aux:NN \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gneg:N { \fp_neg_aux:NN \tl_gset:Nn }
\cs_generate_variant:Nn \fp_neg:N  { c }
\cs_generate_variant:Nn \fp_gneg:N { c }
\cs_new_protected:Npn \fp_neg_aux:NN #1#2
  {
    \group_begin:
      \fp_read:N #2
      \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
      \tl_set:Nx \l_fp_internal_tl
        {
          \if_int_compare:w \l_fp_input_a_sign_int < \c_zero
            +
          \else:
            -
          \fi:
          \int_use:N \l_fp_input_a_integer_int
          .
          \exp_after:wN \use_none:n
            \int_use:N \l_fp_input_a_decimal_int
          e
          \int_use:N \l_fp_input_a_exponent_int
        }
    \exp_after:wN \group_end: \exp_after:wN
    #1 \exp_after:wN #2 \exp_after:wN { \l_fp_internal_tl }
  }
\cs_new_protected_nopar:Npn \fp_add:Nn  { \fp_add_aux:NNn \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gadd:Nn { \fp_add_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_add:Nn   { c }
\cs_generate_variant:Nn \fp_gadd:Nn  { c }
\cs_new_protected:Npn \fp_add_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_read:N #2
      \fp_split:Nn b {#3}
      \fp_standardise:NNNN
        \l_fp_input_b_sign_int
        \l_fp_input_b_integer_int
        \l_fp_input_b_decimal_int
        \l_fp_input_b_exponent_int
      \fp_add_core:
    \fp_tmp:w #1#2
  }
\cs_new_protected_nopar:Npn \fp_add_core:
  {
    \fp_level_input_exponents:
    \if_int_compare:w
      \int_eval:w
        \l_fp_input_a_sign_int * \l_fp_input_b_sign_int
        > \c_zero
      \exp_after:wN \fp_add_sum:
    \else:
      \exp_after:wN \fp_add_difference:
    \fi:
    \l_fp_output_exponent_int \l_fp_input_a_exponent_int
    \fp_standardise:NNNN
      \l_fp_output_sign_int
      \l_fp_output_integer_int
      \l_fp_output_decimal_int
      \l_fp_output_exponent_int
    \cs_set_protected:Npx \fp_tmp:w ##1##2
      {
        \group_end:
        ##1 ##2
          {
             \if_int_compare:w \l_fp_output_sign_int < \c_zero
              -
            \else:
              +
            \fi:
            \int_use:N \l_fp_output_integer_int
            .
            \exp_after:wN \use_none:n
              \int_value:w \int_eval:w
                 \l_fp_output_decimal_int + \c_one_thousand_million
            e
            \int_use:N \l_fp_output_exponent_int
          }
      }
  }
\cs_new_protected_nopar:Npn \fp_add_sum:
  {
    \l_fp_output_sign_int \l_fp_input_a_sign_int
    \l_fp_output_integer_int
      \int_eval:w
        \l_fp_input_a_integer_int + \l_fp_input_b_integer_int
      \scan_stop:
    \l_fp_output_decimal_int
      \int_eval:w
        \l_fp_input_a_decimal_int + \l_fp_input_b_decimal_int
      \scan_stop:
    \if_int_compare:w \l_fp_output_decimal_int < \c_one_thousand_million
    \else:
      \tex_advance:D \l_fp_output_integer_int \c_one
      \tex_advance:D \l_fp_output_decimal_int -\c_one_thousand_million
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_add_difference:
  {
    \l_fp_output_integer_int
      \int_eval:w
        \l_fp_input_a_integer_int - \l_fp_input_b_integer_int
      \scan_stop:
    \l_fp_output_decimal_int
      \int_eval:w
        \l_fp_input_a_decimal_int - \l_fp_input_b_decimal_int
      \scan_stop:
    \if_int_compare:w \l_fp_output_decimal_int < \c_zero
      \tex_advance:D \l_fp_output_integer_int \c_minus_one
      \tex_advance:D \l_fp_output_decimal_int \c_one_thousand_million
    \fi:
    \if_int_compare:w \l_fp_output_integer_int < \c_zero
      \l_fp_output_sign_int \l_fp_input_b_sign_int
      \if_int_compare:w \l_fp_output_decimal_int = \c_zero
        \l_fp_output_integer_int -\l_fp_output_integer_int
      \else:
        \l_fp_output_decimal_int
          \int_eval:w
            \c_one_thousand_million - \l_fp_output_decimal_int
          \scan_stop:
        \l_fp_output_integer_int
           \int_eval:w
             - \l_fp_output_integer_int - \c_one
           \scan_stop:
      \fi:
    \else:
      \l_fp_output_sign_int \l_fp_input_a_sign_int
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_sub:Nn  { \fp_sub_aux:NNn \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gsub:Nn { \fp_sub_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_sub:Nn   { c }
\cs_generate_variant:Nn \fp_gsub:Nn  { c }
\cs_new_protected:Npn \fp_sub_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_read:N #2
      \fp_split:Nn b {#3}
      \fp_standardise:NNNN
        \l_fp_input_b_sign_int
        \l_fp_input_b_integer_int
        \l_fp_input_b_decimal_int
        \l_fp_input_b_exponent_int
      \tex_multiply:D \l_fp_input_b_sign_int \c_minus_one
      \fp_add_core:
    \fp_tmp:w #1#2
  }
\cs_new_protected_nopar:Npn \fp_mul:Nn  { \fp_mul_aux:NNn \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gmul:Nn { \fp_mul_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_mul:Nn  { c }
\cs_generate_variant:Nn \fp_gmul:Nn { c }
\cs_new_protected:Npn \fp_mul_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_read:N #2
      \fp_split:Nn b {#3}
      \fp_standardise:NNNN
        \l_fp_input_b_sign_int
        \l_fp_input_b_integer_int
        \l_fp_input_b_decimal_int
        \l_fp_input_b_exponent_int
      \fp_mul_internal:
      \l_fp_output_exponent_int
        \int_eval:w
          \l_fp_input_a_exponent_int + \l_fp_input_b_exponent_int
        \scan_stop:
      \fp_standardise:NNNN
        \l_fp_output_sign_int
        \l_fp_output_integer_int
        \l_fp_output_decimal_int
        \l_fp_output_exponent_int
      \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          #1 \exp_not:N #2
            {
              \if_int_compare:w
                \int_eval:w
                  \l_fp_input_a_sign_int * \l_fp_input_b_sign_int
                  < \c_zero
                \if_int_compare:w
                  \int_eval:w
                    \l_fp_output_integer_int + \l_fp_output_decimal_int
                    = \c_zero
                  +
                \else:
                  -
                \fi:
              \else:
                +
             \fi:
              \int_use:N \l_fp_output_integer_int
              .
              \exp_after:wN \use_none:n
                \int_value:w \int_eval:w
                   \l_fp_output_decimal_int + \c_one_thousand_million
              e
              \int_use:N \l_fp_output_exponent_int
            }
        }
    \fp_tmp:w
  }
\cs_new_protected_nopar:Npn \fp_mul_internal:
  {
    \fp_mul_split:NNNN \l_fp_input_a_decimal_int
      \l_fp_mul_a_i_int \l_fp_mul_a_ii_int \l_fp_mul_a_iii_int
    \fp_mul_split:NNNN \l_fp_input_b_decimal_int
      \l_fp_mul_b_i_int \l_fp_mul_b_ii_int \l_fp_mul_b_iii_int
    \l_fp_mul_output_int \c_zero
    \tl_clear:N \l_fp_mul_output_tl
    \fp_mul_product:NN \l_fp_mul_a_i_int         \l_fp_mul_b_iii_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int        \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_iii_int       \l_fp_mul_b_i_int
    \tex_divide:D \l_fp_mul_output_int \c_one_thousand
    \fp_mul_product:NN \l_fp_input_a_integer_int \l_fp_mul_b_iii_int
    \fp_mul_product:NN \l_fp_mul_a_i_int         \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int        \l_fp_mul_b_i_int
    \fp_mul_product:NN \l_fp_mul_a_iii_int       \l_fp_input_b_integer_int
    \fp_mul_end_level:
    \fp_mul_product:NN \l_fp_input_a_integer_int \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_i_int         \l_fp_mul_b_i_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int        \l_fp_input_b_integer_int
    \fp_mul_end_level:
    \fp_mul_product:NN \l_fp_input_a_integer_int \l_fp_mul_b_i_int
    \fp_mul_product:NN \l_fp_mul_a_i_int         \l_fp_input_b_integer_int
    \fp_mul_end_level:
    \l_fp_output_decimal_int 0 \l_fp_mul_output_tl \scan_stop:
    \tl_clear:N \l_fp_mul_output_tl
    \fp_mul_product:NN \l_fp_input_a_integer_int \l_fp_input_b_integer_int
    \fp_mul_end_level:
    \l_fp_output_integer_int 0 \l_fp_mul_output_tl \scan_stop:
  }
\cs_new_protected:Npn \fp_mul_split:NNNN #1#2#3#4
  {
    \tex_advance:D #1 \c_one_thousand_million
    \cs_set_protected:Npn \fp_mul_split_aux:w
       ##1##2##3##4##5##6##7##8##9 \q_stop {
        #2 ##2##3##4 \scan_stop:
        #3 ##5##6##7 \scan_stop:
        #4 ##8##9    \scan_stop:
      }
    \exp_after:wN \fp_mul_split_aux:w \int_use:N #1 \q_stop
    \tex_advance:D #1 -\c_one_thousand_million
  }
\cs_new_protected:Npn \fp_mul_product:NN #1#2
  {
    \l_fp_mul_output_int
      \int_eval:w \l_fp_mul_output_int + #1 * #2 \scan_stop:
  }
\cs_new_protected_nopar:Npn \fp_mul_end_level:
  {
    \tex_advance:D \l_fp_mul_output_int \c_one_thousand_million
    \exp_after:wN \use_i:nn \exp_after:wN
      \fp_mul_end_level:NNNNNNNNN \int_use:N \l_fp_mul_output_int
  }
\cs_new_protected:Npn \fp_mul_end_level:NNNNNNNNN #1#2#3#4#5#6#7#8#9
  {
    \tl_set:Nx \l_fp_mul_output_tl { #7#8#9 \l_fp_mul_output_tl }
    \l_fp_mul_output_int #1#2#3#4#5#6 \scan_stop:
  }
\cs_new_protected_nopar:Npn \fp_div:Nn  { \fp_div_aux:NNn \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gdiv:Nn { \fp_div_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_div:Nn  { c }
\cs_generate_variant:Nn \fp_gdiv:Nn { c }
\cs_new_protected:Npn \fp_div_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_read:N #2
      \fp_split:Nn b {#3}
      \fp_standardise:NNNN
        \l_fp_input_b_sign_int
        \l_fp_input_b_integer_int
        \l_fp_input_b_decimal_int
        \l_fp_input_b_exponent_int
      \if_int_compare:w
        \int_eval:w
          \l_fp_input_b_integer_int + \l_fp_input_b_decimal_int
          = \c_zero
        \cs_set_protected:Npx \fp_tmp:w ##1##2
          {
            \group_end:
            #1 \exp_not:N #2 { \c_undefined_fp }
          }
      \else:
        \if_int_compare:w
          \int_eval:w
            \l_fp_input_a_integer_int + \l_fp_input_a_decimal_int
            = \c_zero
          \cs_set_protected:Npx \fp_tmp:w ##1##2
            {
              \group_end:
              #1 \exp_not:N #2 { \c_zero_fp }
            }
        \else:
          \exp_after:wN \exp_after:wN \exp_after:wN \fp_div_internal:
        \fi:
      \fi:
    \fp_tmp:w #1#2
  }
\cs_new_protected_nopar:Npn \fp_div_internal: {
  \l_fp_output_integer_int \c_zero
  \l_fp_output_decimal_int \c_zero
  \cs_set_eq:NN \fp_div_store: \fp_div_store_integer:
  \l_fp_div_offset_int \c_one_hundred_million
  \fp_div_loop:
  \l_fp_output_exponent_int
    \int_eval:w
      \l_fp_input_a_exponent_int - \l_fp_input_b_exponent_int
    \scan_stop:
  \fp_standardise:NNNN
    \l_fp_output_sign_int
    \l_fp_output_integer_int
    \l_fp_output_decimal_int
    \l_fp_output_exponent_int
  \cs_set_protected:Npx \fp_tmp:w ##1##2
    {
      \group_end:
      ##1 ##2
        {
          \if_int_compare:w
            \int_eval:w
              \l_fp_input_a_sign_int * \l_fp_input_b_sign_int
              < \c_zero
            \if_int_compare:w
              \int_eval:w
                \l_fp_output_integer_int + \l_fp_output_decimal_int
                = \c_zero
              +
            \else:
              -
            \fi:
          \else:
            +
          \fi:
          \int_use:N \l_fp_output_integer_int
          .
          \exp_after:wN \use_none:n
            \int_value:w \int_eval:w
               \l_fp_output_decimal_int + \c_one_thousand_million
             \int_eval_end:
          e
          \int_use:N \l_fp_output_exponent_int
        }
    }
}
\cs_new_protected_nopar:Npn \fp_div_loop:
  {
    \l_fp_count_int \c_zero
    \fp_div_divide:
    \fp_div_store:
    \tex_multiply:D \l_fp_input_a_integer_int \c_ten
    \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
    \exp_after:wN \fp_div_loop_step:w
      \int_use:N \l_fp_input_a_decimal_int \q_stop
    \if_int_compare:w
      \int_eval:w \l_fp_input_a_integer_int + \l_fp_input_a_decimal_int
        > \c_zero
        \if_int_compare:w \l_fp_div_offset_int > \c_zero
          \exp_after:wN \exp_after:wN \exp_after:wN
            \fp_div_loop:
        \fi:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_div_divide:
  {
    \if_int_compare:w \l_fp_input_a_integer_int > \l_fp_input_b_integer_int
      \exp_after:wN \fp_div_divide_aux:
    \else:
      \if_int_compare:w \l_fp_input_a_integer_int < \l_fp_input_b_integer_int
      \else:
        \if_int_compare:w
          \l_fp_input_a_decimal_int < \l_fp_input_b_decimal_int
        \else:
          \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \fp_div_divide_aux:
        \fi:
      \fi:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_div_divide_aux:
  {
    \tex_advance:D \l_fp_count_int \c_one
    \tex_advance:D \l_fp_input_a_integer_int -\l_fp_input_b_integer_int
    \tex_advance:D \l_fp_input_a_decimal_int -\l_fp_input_b_decimal_int
    \if_int_compare:w \l_fp_input_a_decimal_int < \c_zero
      \tex_advance:D \l_fp_input_a_integer_int \c_minus_one
      \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
    \fi:
    \fp_div_divide:
  }
\cs_new_protected_nopar:Npn \fp_div_store: { }
\cs_new_protected_nopar:Npn \fp_div_store_integer:
  {
    \l_fp_output_integer_int \l_fp_count_int
    \cs_set_eq:NN \fp_div_store: \fp_div_store_decimal:
  }
\cs_new_protected_nopar:Npn \fp_div_store_decimal:
  {
    \l_fp_output_decimal_int
      \int_eval:w
        \l_fp_output_decimal_int +
        \l_fp_count_int * \l_fp_div_offset_int
      \int_eval_end:
    \tex_divide:D \l_fp_div_offset_int \c_ten
  }
\cs_new_protected:Npn \fp_div_loop_step:w #1#2#3#4#5#6#7#8#9 \q_stop
  {
    \l_fp_input_a_integer_int
      \int_eval:w #2 + \l_fp_input_a_integer_int  \int_eval_end:
    \l_fp_input_a_decimal_int #3#4#5#6#7#8#9 0 \scan_stop:
  }
\cs_new_protected:Npn \fp_add:NNNNNNNNN #1#2#3#4#5#6#7#8#9
  {
    #7 \int_eval:w #1 + #4 \int_eval_end:
    #8 \int_eval:w #2 + #5 \int_eval_end:
    #9 \int_eval:w #3 + #6 \int_eval_end:
    \if_int_compare:w #9 < \c_one_thousand_million
    \else:
      \tex_advance:D #8 \c_one
      \tex_advance:D #9 -\c_one_thousand_million
    \fi:
    \if_int_compare:w #8 < \c_one_thousand_million
    \else:
      \tex_advance:D #7 \c_one
      \tex_advance:D #8 -\c_one_thousand_million
    \fi:
  }
\cs_new_protected:Npn \fp_sub:NNNNNNNNN #1#2#3#4#5#6#7#8#9
  {
    #7 \int_eval:w #1 - #4 \int_eval_end:
    #8 \int_eval:w #2 - #5 \int_eval_end:
    #9 \int_eval:w #3 - #6 \int_eval_end:
    \if_int_compare:w #9 < \c_zero
      \tex_advance:D #8 \c_minus_one
      \tex_advance:D #9 \c_one_thousand_million
    \fi:
    \if_int_compare:w #8 < \c_zero
      \tex_advance:D #7 \c_minus_one
      \tex_advance:D #8 \c_one_thousand_million
    \fi:
    \if_int_compare:w #7 < \c_zero
      \if_int_compare:w \int_eval:w #8 + #9 = \c_zero
        #7 -#7
      \else:
        \tex_advance:D #7 \c_one
        #8 \int_eval:w \c_one_thousand_million - #8 \int_eval_end:
        #9 \int_eval:w \c_one_thousand_million - #9 \int_eval_end:
      \fi:
    \fi:
  }
\cs_new_protected:Npn \fp_mul:NNNNNN #1#2#3#4#5#6
  {
    \fp_mul_split:NNNN #1
      \l_fp_mul_a_i_int \l_fp_mul_a_ii_int \l_fp_mul_a_iii_int
    \fp_mul_split:NNNN #2
      \l_fp_mul_a_iv_int \l_fp_mul_a_v_int \l_fp_mul_a_vi_int
    \fp_mul_split:NNNN #3
      \l_fp_mul_b_i_int \l_fp_mul_b_ii_int \l_fp_mul_b_iii_int
    \fp_mul_split:NNNN #4
      \l_fp_mul_b_iv_int \l_fp_mul_b_v_int \l_fp_mul_b_vi_int
    \l_fp_mul_output_int \c_zero
    \tl_clear:N \l_fp_mul_output_tl
    \fp_mul_product:NN \l_fp_mul_a_i_int         \l_fp_mul_b_vi_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int        \l_fp_mul_b_v_int
    \fp_mul_product:NN \l_fp_mul_a_iii_int       \l_fp_mul_b_iv_int
    \fp_mul_product:NN \l_fp_mul_a_iv_int        \l_fp_mul_b_iii_int
    \fp_mul_product:NN \l_fp_mul_a_v_int         \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_vi_int        \l_fp_mul_b_i_int
    \tex_divide:D \l_fp_mul_output_int \c_one_thousand
    \fp_mul_product:NN \l_fp_mul_a_i_int        \l_fp_mul_b_v_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int       \l_fp_mul_b_iv_int
    \fp_mul_product:NN \l_fp_mul_a_iii_int      \l_fp_mul_b_iii_int
    \fp_mul_product:NN \l_fp_mul_a_iv_int       \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_v_int        \l_fp_mul_b_i_int
    \fp_mul_end_level:
    \fp_mul_product:NN \l_fp_mul_a_i_int        \l_fp_mul_b_iv_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int       \l_fp_mul_b_iii_int
    \fp_mul_product:NN \l_fp_mul_a_iii_int      \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_iv_int       \l_fp_mul_b_i_int
    \fp_mul_end_level:
    \fp_mul_product:NN \l_fp_mul_a_i_int        \l_fp_mul_b_iii_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int       \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_iii_int      \l_fp_mul_b_i_int
    \fp_mul_end_level:
    #6 0 \l_fp_mul_output_tl \scan_stop:
    \tl_clear:N \l_fp_mul_output_tl
    \fp_mul_product:NN \l_fp_mul_a_i_int        \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int       \l_fp_mul_b_i_int
    \fp_mul_end_level:
    \fp_mul_product:NN \l_fp_mul_a_i_int        \l_fp_mul_b_i_int
    \fp_mul_end_level:
    \fp_mul_end_level:
    #5 0 \l_fp_mul_output_tl \scan_stop:
  }
\cs_new_protected:Npn \fp_mul:NNNNNNNNN #1#2#3#4#5#6#7#8#9
  {
    \fp_mul_split:NNNN #2
      \l_fp_mul_a_i_int \l_fp_mul_a_ii_int \l_fp_mul_a_iii_int
    \fp_mul_split:NNNN #3
      \l_fp_mul_a_iv_int \l_fp_mul_a_v_int \l_fp_mul_a_vi_int
    \fp_mul_split:NNNN #5
      \l_fp_mul_b_i_int \l_fp_mul_b_ii_int \l_fp_mul_b_iii_int
    \fp_mul_split:NNNN #6
      \l_fp_mul_b_iv_int \l_fp_mul_b_v_int \l_fp_mul_b_vi_int
    \l_fp_mul_output_int \c_zero
    \tl_clear:N \l_fp_mul_output_tl
    \fp_mul_product:NN \l_fp_mul_a_i_int         \l_fp_mul_b_vi_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int        \l_fp_mul_b_v_int
    \fp_mul_product:NN \l_fp_mul_a_iii_int       \l_fp_mul_b_iv_int
    \fp_mul_product:NN \l_fp_mul_a_iv_int        \l_fp_mul_b_iii_int
    \fp_mul_product:NN \l_fp_mul_a_v_int         \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_vi_int        \l_fp_mul_b_i_int
    \tex_divide:D \l_fp_mul_output_int \c_one_thousand
    \fp_mul_product:NN #1                       \l_fp_mul_b_vi_int
    \fp_mul_product:NN \l_fp_mul_a_i_int        \l_fp_mul_b_v_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int       \l_fp_mul_b_iv_int
    \fp_mul_product:NN \l_fp_mul_a_iii_int      \l_fp_mul_b_iii_int
    \fp_mul_product:NN \l_fp_mul_a_iv_int       \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_v_int        \l_fp_mul_b_i_int
    \fp_mul_product:NN \l_fp_mul_a_vi_int       #4
    \fp_mul_end_level:
    \fp_mul_product:NN #1                       \l_fp_mul_b_v_int
    \fp_mul_product:NN \l_fp_mul_a_i_int        \l_fp_mul_b_iv_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int       \l_fp_mul_b_iii_int
    \fp_mul_product:NN \l_fp_mul_a_iii_int      \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_iv_int       \l_fp_mul_b_i_int
    \fp_mul_product:NN \l_fp_mul_a_v_int        #4
    \fp_mul_end_level:
    \fp_mul_product:NN #1                       \l_fp_mul_b_iv_int
    \fp_mul_product:NN \l_fp_mul_a_i_int        \l_fp_mul_b_iii_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int       \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_iii_int      \l_fp_mul_b_i_int
    \fp_mul_product:NN \l_fp_mul_a_iv_int       #4
    \fp_mul_end_level:
    #9 0 \l_fp_mul_output_tl \scan_stop:
    \tl_clear:N \l_fp_mul_output_tl
    \fp_mul_product:NN #1                       \l_fp_mul_b_iii_int
    \fp_mul_product:NN \l_fp_mul_a_i_int        \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int       \l_fp_mul_b_i_int
    \fp_mul_product:NN \l_fp_mul_a_iii_int      #4
    \fp_mul_end_level:
    \fp_mul_product:NN #1                       \l_fp_mul_b_ii_int
    \fp_mul_product:NN \l_fp_mul_a_i_int        \l_fp_mul_b_i_int
    \fp_mul_product:NN \l_fp_mul_a_ii_int       #4
    \fp_mul_end_level:
    \fp_mul_product:NN #1                       \l_fp_mul_b_i_int
    \fp_mul_product:NN \l_fp_mul_a_i_int        #4
    \fp_mul_end_level:
    #8 0 \l_fp_mul_output_tl \scan_stop:
    \tl_clear:N \l_fp_mul_output_tl
    \fp_mul_product:NN #1 #4
    \fp_mul_end_level:
    #7 0 \l_fp_mul_output_tl \scan_stop:
  }
\cs_new_protected:Npn \fp_div_integer:NNNNN #1#2#3#4#5
  {
    \l_fp_internal_int #1
    \tex_divide:D \l_fp_internal_int #3
    \l_fp_internal_int \int_eval:w #1 - \l_fp_internal_int * #3 \int_eval_end:
    #4 #1
    \tex_divide:D #4 #3
    #5 #2
    \tex_divide:D #5 #3
    \tex_multiply:D \l_fp_internal_int \c_one_thousand
    \tex_divide:D \l_fp_internal_int #3
    #5 \int_eval:w #5 + \l_fp_internal_int * \c_one_million \int_eval_end:
    \if_int_compare:w #5 > \c_one_thousand_million
      \tex_advance:D #4 \c_one
      \tex_advance:D #5 -\c_one_thousand_million
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_extended_normalise:
  {
    \fp_extended_normalise_aux_i:
    \fp_extended_normalise_aux_ii:
  }
\cs_new_protected_nopar:Npn \fp_extended_normalise_aux_i:
  {
    \if_int_compare:w \l_fp_input_a_exponent_int > \c_zero
      \tex_multiply:D \l_fp_input_a_integer_int \c_ten
      \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
      \exp_after:wN \fp_extended_normalise_aux_i:w
        \int_use:N \l_fp_input_a_decimal_int \q_stop
       \exp_after:wN \fp_extended_normalise_aux_i:
     \fi:
  }
\cs_new_protected:Npn \fp_extended_normalise_aux_i:w
  #1#2#3#4#5#6#7#8#9 \q_stop
  {
    \l_fp_input_a_integer_int
      \int_eval:w \l_fp_input_a_integer_int + #2 \scan_stop:
    \l_fp_input_a_decimal_int #3#4#5#6#7#8#9 0 \scan_stop:
    \tex_advance:D \l_fp_input_a_extended_int \c_one_thousand_million
    \exp_after:wN \fp_extended_normalise_aux_ii:w
      \int_use:N \l_fp_input_a_extended_int \q_stop
  }
\cs_new_protected:Npn \fp_extended_normalise_aux_ii:w
  #1#2#3#4#5#6#7#8#9 \q_stop
  {
    \l_fp_input_a_decimal_int
      \int_eval:w \l_fp_input_a_decimal_int + #2 \scan_stop:
    \l_fp_input_a_extended_int #3#4#5#6#7#8#9 0 \scan_stop:
    \tex_advance:D \l_fp_input_a_exponent_int \c_minus_one
  }
\cs_new_protected_nopar:Npn \fp_extended_normalise_aux_ii:
  {
    \if_int_compare:w \l_fp_input_a_exponent_int < \c_zero
      \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
      \exp_after:wN \use_i:nn \exp_after:wN
        \fp_extended_normalise_ii_aux:NNNNNNNNN
        \int_use:N \l_fp_input_a_decimal_int
       \exp_after:wN \fp_extended_normalise_aux_ii:
     \fi:
  }
\cs_new_protected:Npn \fp_extended_normalise_ii_aux:NNNNNNNNN
  #1#2#3#4#5#6#7#8#9
  {
    \if_int_compare:w \l_fp_input_a_integer_int = \c_zero
      \l_fp_input_a_decimal_int #1#2#3#4#5#6#7#8 \scan_stop:
    \else:
      \tl_set:Nx \l_fp_internal_tl
        {
          \int_use:N \l_fp_input_a_integer_int
          #1#2#3#4#5#6#7#8
        }
      \l_fp_input_a_integer_int \c_zero
      \l_fp_input_a_decimal_int \l_fp_internal_tl \scan_stop:
    \fi:
    \tex_divide:D \l_fp_input_a_extended_int \c_ten
    \tl_set:Nx \l_fp_internal_tl
      {
        #9
        \int_use:N \l_fp_input_a_extended_int
      }
    \l_fp_input_a_extended_int \l_fp_internal_tl \scan_stop:
    \tex_advance:D \l_fp_input_a_exponent_int \c_one
  }
\cs_new_protected_nopar:Npn \fp_extended_normalise_output:
  {
    \if_int_compare:w \l_fp_output_integer_int > \c_nine
      \tex_advance:D \l_fp_output_integer_int \c_one_thousand_million
      \exp_after:wN \use_i:nn \exp_after:wN
        \fp_extended_normalise_output_aux_i:NNNNNNNNN
        \int_use:N \l_fp_output_integer_int
      \exp_after:wN \fp_extended_normalise_output:
    \fi:
  }
\cs_new_protected:Npn \fp_extended_normalise_output_aux_i:NNNNNNNNN
  #1#2#3#4#5#6#7#8#9
  {
    \l_fp_output_integer_int #1#2#3#4#5#6#7#8 \scan_stop:
    \tex_advance:D \l_fp_output_decimal_int \c_one_thousand_million
    \tl_set:Nx \l_fp_internal_tl
      {
        #9
        \exp_after:wN \use_none:n
        \int_use:N \l_fp_output_decimal_int
      }
    \exp_after:wN \fp_extended_normalise_output_aux_ii:NNNNNNNNN
      \l_fp_internal_tl
  }
\cs_new_protected:Npn \fp_extended_normalise_output_aux_ii:NNNNNNNNN
  #1#2#3#4#5#6#7#8#9
  {
    \l_fp_output_decimal_int #1#2#3#4#5#6#7#8#9 \scan_stop:
    \fp_extended_normalise_output_aux:N
  }
\cs_new_protected:Npn \fp_extended_normalise_output_aux:N #1
  {
    \tex_advance:D \l_fp_output_extended_int \c_one_thousand_million
    \tex_divide:D \l_fp_output_extended_int \c_ten
    \tl_set:Nx \l_fp_internal_tl
      {
        #1
        \exp_after:wN \use_none:n
          \int_use:N \l_fp_output_extended_int
      }
    \l_fp_output_extended_int \l_fp_internal_tl \scan_stop:
    \tex_advance:D \l_fp_output_exponent_int \c_one
  }
\cs_new_protected_nopar:Npn \fp_trig_normalise:
  {
    \if_int_compare:w \l_fp_input_a_exponent_int < \c_ten
      \l_fp_input_a_extended_int \c_zero
      \fp_extended_normalise:
      \fp_trig_normalise_aux:
      \if_int_compare:w \l_fp_input_a_integer_int < \c_zero
        \l_fp_input_a_sign_int -\l_fp_input_a_sign_int
        \l_fp_input_a_integer_int -\l_fp_input_a_integer_int
      \fi:
       \exp_after:wN \fp_trig_octant:
    \else:
      \l_fp_input_a_sign_int    \c_one
      \l_fp_output_integer_int  \c_zero
      \l_fp_output_decimal_int  \c_zero
      \l_fp_output_exponent_int \c_zero
      \exp_after:wN \fp_trig_overflow_msg:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_trig_normalise_aux:
  {
    \if_int_compare:w \l_fp_input_a_integer_int > \c_three
      \fp_trig_sub:NNN
        \c_six \c_fp_two_pi_decimal_int \c_fp_two_pi_extended_int
      \exp_after:wN \fp_trig_normalise_aux:
    \else:
      \if_int_compare:w \l_fp_input_a_integer_int > \c_two
        \if_int_compare:w \l_fp_input_a_decimal_int > \c_fp_pi_decimal_int
          \fp_trig_sub:NNN
            \c_six \c_fp_two_pi_decimal_int \c_fp_two_pi_extended_int
          \exp_after:wN \exp_after:wN \exp_after:wN
          \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \fp_trig_normalise_aux:
          \fi:
      \fi:
    \fi:
  }
\cs_new_protected:Npn \fp_trig_sub:NNN #1#2#3
  {
    \l_fp_input_a_integer_int
      \int_eval:w \l_fp_input_a_integer_int - #1 \int_eval_end:
    \l_fp_input_a_decimal_int
      \int_eval:w \l_fp_input_a_decimal_int - #2 \int_eval_end:
    \l_fp_input_a_extended_int
      \int_eval:w \l_fp_input_a_extended_int - #3 \int_eval_end:
    \if_int_compare:w \l_fp_input_a_extended_int < \c_zero
      \tex_advance:D \l_fp_input_a_decimal_int \c_minus_one
      \tex_advance:D \l_fp_input_a_extended_int \c_one_thousand_million
    \fi:
    \if_int_compare:w \l_fp_input_a_decimal_int < \c_zero
      \tex_advance:D \l_fp_input_a_integer_int \c_minus_one
      \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
    \fi:
    \if_int_compare:w \l_fp_input_a_integer_int < \c_zero
      \l_fp_input_a_sign_int -\l_fp_input_a_sign_int
      \if_int_compare:w
        \int_eval:w
          \l_fp_input_a_decimal_int + \l_fp_input_a_extended_int
        = \c_zero
        \l_fp_input_a_integer_int -\l_fp_input_a_integer_int
      \else:
        \l_fp_input_a_integer_int
           \int_eval:w
             - \l_fp_input_a_integer_int - \c_one
           \int_eval_end:
        \l_fp_input_a_decimal_int
          \int_eval:w
            \c_one_thousand_million - \l_fp_input_a_decimal_int
          \int_eval_end:
        \l_fp_input_a_extended_int
          \int_eval:w
            \c_one_thousand_million - \l_fp_input_a_extended_int
          \int_eval_end:
      \fi:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_trig_octant:
  {
    \l_fp_trig_octant_int \c_one
    \fp_trig_octant_aux_i:
    \if_int_compare:w \l_fp_input_a_decimal_int < \c_ten
      \l_fp_input_a_decimal_int  \c_zero
      \l_fp_input_a_extended_int \c_zero
    \fi:
    \if_int_odd:w \l_fp_trig_octant_int
    \else:
      \fp_sub:NNNNNNNNN
        \c_zero \c_fp_pi_by_four_decimal_int \c_fp_pi_by_four_extended_int
        \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
          \l_fp_input_a_extended_int
        \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
          \l_fp_input_a_extended_int
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_trig_octant_aux_i:
  {
    \if_int_compare:w \l_fp_trig_octant_int > \c_four
      \l_fp_trig_octant_int \c_four
      \l_fp_input_a_decimal_int  \c_fp_pi_by_four_decimal_int
      \l_fp_input_a_extended_int \c_fp_pi_by_four_extended_int
    \else:
      \exp_after:wN \fp_trig_octant_aux_ii:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_trig_octant_aux_ii:
  {
    \if_int_compare:w \l_fp_input_a_integer_int > \c_zero
      \fp_sub:NNNNNNNNN
        \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
          \l_fp_input_a_extended_int
        \c_zero \c_fp_pi_by_four_decimal_int \c_fp_pi_by_four_extended_int
        \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
          \l_fp_input_a_extended_int
      \tex_advance:D \l_fp_trig_octant_int \c_one
      \exp_after:wN \fp_trig_octant_aux_i:
    \else:
      \if_int_compare:w
        \l_fp_input_a_decimal_int > \c_fp_pi_by_four_decimal_int
        \fp_sub:NNNNNNNNN
          \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
            \l_fp_input_a_extended_int
          \c_zero \c_fp_pi_by_four_decimal_int
            \c_fp_pi_by_four_extended_int
          \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
            \l_fp_input_a_extended_int
        \tex_advance:D \l_fp_trig_octant_int \c_one
        \exp_after:wN \exp_after:wN \exp_after:wN
          \fp_trig_octant_aux_i:
      \fi:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_sin:Nn  { \fp_sin_aux:NNn \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gsin:Nn { \fp_sin_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_sin:Nn   { c }
\cs_generate_variant:Nn \fp_gsin:Nn  { c }
\cs_new_protected:Npn \fp_sin_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_split:Nn a {#3}
      \fp_standardise:NNNN
        \l_fp_input_a_sign_int
        \l_fp_input_a_integer_int
        \l_fp_input_a_decimal_int
        \l_fp_input_a_exponent_int
      \tl_set:Nx \l_fp_arg_tl
        {
          \if_int_compare:w \l_fp_input_a_sign_int < \c_zero
            -
          \else:
            +
          \fi:
          \int_use:N \l_fp_input_a_integer_int
          .
          \exp_after:wN \use_none:n
            \int_value:w \int_eval:w
              \l_fp_input_a_decimal_int + \c_one_thousand_million
          e
          \int_use:N \l_fp_input_a_exponent_int
        }
      \if_int_compare:w \l_fp_input_a_exponent_int < -\c_five
        \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          #1 \exp_not:N #2 { \l_fp_arg_tl }
        }
      \else:
        \if_cs_exist:w
          c_fp_sin ( \l_fp_arg_tl ) _fp
        \cs_end:
        \else:
          \exp_after:wN \exp_after:wN \exp_after:wN
            \fp_sin_aux_i:
        \fi:
        \cs_set_protected_nopar:Npx \fp_tmp:w
          {
            \group_end:
            #1 \exp_not:N #2
              { \use:c { c_fp_sin ( \l_fp_arg_tl ) _fp } }
          }
      \fi:
    \fp_tmp:w
  }
\cs_new_protected_nopar:Npn \fp_sin_aux_i:
  {
    \fp_trig_normalise:
    \fp_sin_aux_ii:
    \if_int_compare:w \l_fp_output_integer_int = \c_one
      \l_fp_output_exponent_int \c_zero
    \else:
      \l_fp_output_integer_int \l_fp_output_decimal_int
      \l_fp_output_decimal_int \l_fp_output_extended_int
      \l_fp_output_exponent_int -\c_nine
    \fi:
    \fp_standardise:NNNN
      \l_fp_input_a_sign_int
      \l_fp_output_integer_int
      \l_fp_output_decimal_int
      \l_fp_output_exponent_int
    \tl_new:c { c_fp_sin ( \l_fp_arg_tl ) _fp }
    \tl_gset:cx { c_fp_sin ( \l_fp_arg_tl ) _fp }
      {
        \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
          +
        \else:
          -
        \fi:
        \int_use:N \l_fp_output_integer_int
        .
        \exp_after:wN \use_none:n
          \int_value:w \int_eval:w
             \l_fp_output_decimal_int + \c_one_thousand_million
        e
        \int_use:N \l_fp_output_exponent_int
      }
  }
\cs_new_protected_nopar:Npn \fp_sin_aux_ii:
  {
    \if_case:w \l_fp_trig_octant_int
    \or:
      \exp_after:wN \fp_trig_calc_sin:
    \or:
      \exp_after:wN \fp_trig_calc_cos:
    \or:
      \exp_after:wN \fp_trig_calc_cos:
    \or:
      \exp_after:wN \fp_trig_calc_sin:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_cos:Nn  { \fp_cos_aux:NNn \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gcos:Nn { \fp_cos_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_cos:Nn   { c }
\cs_generate_variant:Nn \fp_gcos:Nn  { c }
\cs_new_protected:Npn \fp_cos_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_split:Nn a {#3}
      \fp_standardise:NNNN
        \l_fp_input_a_sign_int
        \l_fp_input_a_integer_int
        \l_fp_input_a_decimal_int
        \l_fp_input_a_exponent_int
      \tl_set:Nx \l_fp_arg_tl
        {
          \if_int_compare:w \l_fp_input_a_sign_int < \c_zero
            -
          \else:
            +
          \fi:
          \int_use:N \l_fp_input_a_integer_int
          .
        \exp_after:wN \use_none:n
          \int_value:w \int_eval:w
             \l_fp_input_a_decimal_int + \c_one_thousand_million
          e
          \int_use:N \l_fp_input_a_exponent_int
        }
      \if_cs_exist:w c_fp_cos ( \l_fp_arg_tl ) _fp \cs_end:
      \else:
        \exp_after:wN \fp_cos_aux_i:
      \fi:
      \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          #1 \exp_not:N #2
            { \use:c { c_fp_cos ( \l_fp_arg_tl ) _fp } }
        }
    \fp_tmp:w
  }
\cs_new_protected_nopar:Npn \fp_cos_aux_i:
  {
    \fp_trig_normalise:
    \fp_cos_aux_ii:
    \if_int_compare:w \l_fp_output_integer_int = \c_one
      \l_fp_output_exponent_int \c_zero
    \else:
      \l_fp_output_integer_int \l_fp_output_decimal_int
      \l_fp_output_decimal_int \l_fp_output_extended_int
      \l_fp_output_exponent_int -\c_nine
    \fi:
    \fp_standardise:NNNN
      \l_fp_input_a_sign_int
      \l_fp_output_integer_int
      \l_fp_output_decimal_int
      \l_fp_output_exponent_int
    \tl_new:c { c_fp_cos ( \l_fp_arg_tl ) _fp }
    \tl_gset:cx { c_fp_cos ( \l_fp_arg_tl ) _fp }
      {
        \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
          +
        \else:
          -
        \fi:
        \int_use:N \l_fp_output_integer_int
        .
        \exp_after:wN \use_none:n
          \int_value:w \int_eval:w
             \l_fp_output_decimal_int + \c_one_thousand_million
        e
        \int_use:N \l_fp_output_exponent_int
      }
  }
\cs_new_protected_nopar:Npn \fp_cos_aux_ii:
  {
    \if_case:w \l_fp_trig_octant_int
    \or:
      \exp_after:wN \fp_trig_calc_cos:
    \or:
      \exp_after:wN \fp_trig_calc_sin:
    \or:
      \exp_after:wN \fp_trig_calc_sin:
    \or:
      \exp_after:wN \fp_trig_calc_cos:
    \fi:
    \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
      \if_int_compare:w \l_fp_trig_octant_int > \c_two
        \l_fp_input_a_sign_int \c_minus_one
      \fi:
    \else:
      \if_int_compare:w \l_fp_trig_octant_int > \c_two
      \else:
        \l_fp_input_a_sign_int \c_one
      \fi:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_trig_calc_cos:
  {
    \if_int_compare:w \l_fp_input_a_decimal_int = \c_zero
      \l_fp_output_integer_int \c_one
      \l_fp_output_decimal_int \c_zero
    \else:
      \l_fp_trig_sign_int \c_minus_one
      \fp_mul:NNNNNN
        \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
        \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
        \l_fp_trig_decimal_int \l_fp_trig_extended_int
      \fp_div_integer:NNNNN
        \l_fp_trig_decimal_int \l_fp_trig_extended_int
        \c_two
        \l_fp_trig_decimal_int \l_fp_trig_extended_int
      \l_fp_count_int \c_three
      \if_int_compare:w \l_fp_trig_extended_int = \c_zero
        \if_int_compare:w \l_fp_trig_decimal_int = \c_zero
          \l_fp_output_integer_int \c_one
          \l_fp_output_decimal_int \c_zero
          \l_fp_output_extended_int \c_zero
        \else:
          \l_fp_output_integer_int \c_zero
          \l_fp_output_decimal_int \c_one_thousand_million
          \l_fp_output_extended_int \c_zero
        \fi:
      \else:
        \l_fp_output_integer_int \c_zero
        \l_fp_output_decimal_int 999999999 \scan_stop:
        \l_fp_output_extended_int \c_one_thousand_million
      \fi:
      \tex_advance:D \l_fp_output_extended_int -\l_fp_trig_extended_int
      \tex_advance:D \l_fp_output_decimal_int -\l_fp_trig_decimal_int
      \exp_after:wN \fp_trig_calc_Taylor:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_trig_calc_sin:
  {
    \l_fp_output_integer_int \c_zero
    \if_int_compare:w \l_fp_input_a_decimal_int = \c_zero
      \l_fp_output_decimal_int \c_zero
    \else:
      \l_fp_output_decimal_int \l_fp_input_a_decimal_int
      \l_fp_output_extended_int \l_fp_input_a_extended_int
      \l_fp_trig_sign_int \c_one
      \l_fp_trig_decimal_int \l_fp_input_a_decimal_int
      \l_fp_trig_extended_int \l_fp_input_a_extended_int
      \l_fp_count_int \c_two
      \exp_after:wN \fp_trig_calc_Taylor:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_trig_calc_Taylor:
  {
    \l_fp_trig_sign_int -\l_fp_trig_sign_int
    \fp_mul:NNNNNN
      \l_fp_trig_decimal_int \l_fp_trig_extended_int
      \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
      \l_fp_trig_decimal_int \l_fp_trig_extended_int
    \fp_mul:NNNNNN
      \l_fp_trig_decimal_int \l_fp_trig_extended_int
      \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
      \l_fp_trig_decimal_int \l_fp_trig_extended_int
    \fp_div_integer:NNNNN
      \l_fp_trig_decimal_int \l_fp_trig_extended_int
      \l_fp_count_int
      \l_fp_trig_decimal_int \l_fp_trig_extended_int
    \tex_advance:D \l_fp_count_int \c_one
    \fp_div_integer:NNNNN
      \l_fp_trig_decimal_int \l_fp_trig_extended_int
      \l_fp_count_int
      \l_fp_trig_decimal_int \l_fp_trig_extended_int
    \tex_advance:D \l_fp_count_int \c_one
    \if_int_compare:w \l_fp_trig_decimal_int > \c_zero
      \if_int_compare:w \l_fp_trig_sign_int > \c_zero
        \tex_advance:D \l_fp_output_decimal_int \l_fp_trig_decimal_int
        \tex_advance:D \l_fp_output_extended_int
          \l_fp_trig_extended_int
        \if_int_compare:w \l_fp_output_extended_int < \c_one_thousand_million
        \else:
          \tex_advance:D \l_fp_output_decimal_int \c_one
          \tex_advance:D \l_fp_output_extended_int
            -\c_one_thousand_million
        \fi:
        \if_int_compare:w \l_fp_output_decimal_int < \c_one_thousand_million
        \else:
          \tex_advance:D \l_fp_output_integer_int \c_one
          \tex_advance:D \l_fp_output_decimal_int
            -\c_one_thousand_million
        \fi:
      \else:
        \tex_advance:D \l_fp_output_decimal_int -\l_fp_trig_decimal_int
        \tex_advance:D \l_fp_output_extended_int
          -\l_fp_input_a_extended_int
        \if_int_compare:w \l_fp_output_extended_int < \c_zero
          \tex_advance:D \l_fp_output_decimal_int \c_minus_one
          \tex_advance:D \l_fp_output_extended_int \c_one_thousand_million
        \fi:
        \if_int_compare:w \l_fp_output_decimal_int < \c_zero
          \tex_advance:D \l_fp_output_integer_int \c_minus_one
          \tex_advance:D \l_fp_output_decimal_int \c_one_thousand_million
        \fi:
      \fi:
      \exp_after:wN \fp_trig_calc_Taylor:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_tan:Nn  { \fp_tan_aux:NNn \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gtan:Nn { \fp_tan_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_tan:Nn   { c }
\cs_generate_variant:Nn \fp_gtan:Nn  { c }
\cs_new_protected:Npn \fp_tan_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_split:Nn a {#3}
      \fp_standardise:NNNN
        \l_fp_input_a_sign_int
        \l_fp_input_a_integer_int
        \l_fp_input_a_decimal_int
        \l_fp_input_a_exponent_int
      \tl_set:Nx \l_fp_arg_tl
        {
          \if_int_compare:w \l_fp_input_a_sign_int < \c_zero
            -
          \else:
            +
          \fi:
          \int_use:N \l_fp_input_a_integer_int
          .
          \exp_after:wN \use_none:n
            \int_value:w \int_eval:w
              \l_fp_input_a_decimal_int + \c_one_thousand_million
          e
          \int_use:N \l_fp_input_a_exponent_int
        }
      \if_int_compare:w \l_fp_input_a_exponent_int < -\c_five
        \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          #1 \exp_not:N #2 { \l_fp_arg_tl }
        }
      \else:
        \if_cs_exist:w
          c_fp_tan ( \l_fp_arg_tl ) _fp
        \cs_end:
        \else:
          \exp_after:wN \exp_after:wN \exp_after:wN
            \fp_tan_aux_i:
        \fi:
        \cs_set_protected_nopar:Npx \fp_tmp:w
          {
            \group_end:
            #1 \exp_not:N #2
              { \use:c { c_fp_tan ( \l_fp_arg_tl ) _fp } }
          }
      \fi:
    \fp_tmp:w
  }
\cs_new_protected_nopar:Npn \fp_tan_aux_i:
  {
    \if_int_compare:w \l_fp_input_a_exponent_int < \c_ten
      \exp_after:wN \fp_tan_aux_ii:
    \else:
      \cs_new_eq:cN { c_fp_tan ( \l_fp_arg_tl ) _fp }
        \c_zero_fp
      \exp_after:wN \fp_trig_overflow_msg:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_tan_aux_ii:
  {
    \fp_trig_normalise:
    \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
      \if_int_compare:w \l_fp_trig_octant_int > \c_two
        \l_fp_output_sign_int \c_minus_one
      \else:
        \l_fp_output_sign_int \c_one
      \fi:
    \else:
      \if_int_compare:w \l_fp_trig_octant_int > \c_two
        \l_fp_output_sign_int \c_one
      \else:
        \l_fp_output_sign_int \c_minus_one
      \fi:
    \fi:
    \fp_cos_aux_ii:
    \if_int_compare:w \l_fp_input_a_decimal_int = \c_zero
      \if_int_compare:w \l_fp_input_a_integer_int = \c_zero
        \cs_new_eq:cN { c_fp_tan ( \l_fp_arg_tl ) _fp }
          \c_undefined_fp
      \else:
        \exp_after:wN \exp_after:wN \exp_after:wN
          \fp_tan_aux_iii:
      \fi:
    \else:
      \exp_after:wN \fp_tan_aux_iii:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_tan_aux_iii:
  {
    \l_fp_input_b_integer_int \l_fp_output_decimal_int
    \l_fp_input_b_decimal_int \l_fp_output_extended_int
    \l_fp_input_b_exponent_int -\c_nine
    \fp_standardise:NNNN
      \l_fp_input_b_sign_int
      \l_fp_input_b_integer_int
      \l_fp_input_b_decimal_int
      \l_fp_input_b_exponent_int
    \fp_sin_aux_ii:
    \l_fp_input_a_integer_int \l_fp_output_decimal_int
    \l_fp_input_a_decimal_int \l_fp_output_extended_int
    \l_fp_input_a_exponent_int -\c_nine
    \fp_standardise:NNNN
      \l_fp_input_a_sign_int
      \l_fp_input_a_integer_int
      \l_fp_input_a_decimal_int
      \l_fp_input_a_exponent_int
    \if_int_compare:w \l_fp_input_a_decimal_int = \c_zero
      \if_int_compare:w \l_fp_input_a_integer_int = \c_zero
        \cs_new_eq:cN { c_fp_tan ( \l_fp_arg_tl ) _fp }
          \c_zero_fp
      \else:
        \exp_after:wN \exp_after:wN \exp_after:wN \fp_tan_aux_iv:
      \fi:
    \else:
      \exp_after:wN \fp_tan_aux_iv:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_tan_aux_iv:
  {
    \l_fp_output_integer_int \c_zero
    \l_fp_output_decimal_int \c_zero
    \cs_set_eq:NN \fp_div_store: \fp_div_store_integer:
    \l_fp_div_offset_int \c_one_hundred_million
    \fp_div_loop:
    \l_fp_output_exponent_int
      \int_eval:w
        \l_fp_input_a_exponent_int - \l_fp_input_b_exponent_int
      \int_eval_end:
    \fp_standardise:NNNN
      \l_fp_output_sign_int
      \l_fp_output_integer_int
      \l_fp_output_decimal_int
      \l_fp_output_exponent_int
    \tl_new:c { c_fp_tan ( \l_fp_arg_tl ) _fp }
    \tl_gset:cx { c_fp_tan ( \l_fp_arg_tl ) _fp }
      {
        \if_int_compare:w \l_fp_output_sign_int > \c_zero
          +
        \else:
          -
        \fi:
        \int_use:N \l_fp_output_integer_int
        .
        \exp_after:wN \use_none:n
          \int_value:w \int_eval:w
             \l_fp_output_decimal_int + \c_one_thousand_million
        e
        \int_use:N \l_fp_output_exponent_int
      }
  }
\tl_const:cn { c_fp_exp_1_tl }   { { 2 } { 718281828 } { 459045235 } { 0 } }
\tl_const:cn { c_fp_exp_2_tl }   { { 7 } { 389056098 } { 930650227 } { 0 } }
\tl_const:cn { c_fp_exp_3_tl }   { { 2 } { 008553692 } { 318766774 } { 1 } }
\tl_const:cn { c_fp_exp_4_tl }   { { 5 } { 459815003 } { 314423908 } { 1 } }
\tl_const:cn { c_fp_exp_5_tl }   { { 1 } { 484131591 } { 025766034 } { 2 } }
\tl_const:cn { c_fp_exp_6_tl }   { { 4 } { 034287934 } { 927351226 } { 2 } }
\tl_const:cn { c_fp_exp_7_tl }   { { 1 } { 096633158 } { 428458599 } { 3 } }
\tl_const:cn { c_fp_exp_8_tl }   { { 2 } { 980957987 } { 041728275 } { 3 } }
\tl_const:cn { c_fp_exp_9_tl }   { { 8 } { 103083927 } { 575384008 } { 3 } }
\tl_const:cn { c_fp_exp_10_tl }  { { 2 } { 202646579 } { 480671652 } { 4 } }
\tl_const:cn { c_fp_exp_20_tl }  { { 4 } { 851651954 } { 097902280 } { 8 } }
\tl_const:cn { c_fp_exp_30_tl }  { { 1 } { 068647458 } { 152446215 } { 13 } }
\tl_const:cn { c_fp_exp_40_tl }  { { 2 } { 353852668 } { 370199854 } { 17 } }
\tl_const:cn { c_fp_exp_50_tl }  { { 5 } { 184705528 } { 587072464 } { 21 } }
\tl_const:cn { c_fp_exp_60_tl }  { { 1 } { 142007389 } { 815684284 } { 26 } }
\tl_const:cn { c_fp_exp_70_tl }  { { 2 } { 515438670 } { 919167006 } { 30 } }
\tl_const:cn { c_fp_exp_80_tl }  { { 5 } { 540622384 } { 393510053 } { 34 } }
\tl_const:cn { c_fp_exp_90_tl }  { { 1 } { 220403294 } { 317840802 } { 39 } }
\tl_const:cn { c_fp_exp_100_tl } { { 2 } { 688117141 } { 816135448 } { 43 } }
\tl_const:cn { c_fp_exp_200_tl } { { 7 } { 225973768 } { 125749258 } { 86 } }
\tl_const:cn { c_fp_exp_-1_tl }   { { 3 } { 678794411 } { 71442322 }  { -1 } }
\tl_const:cn { c_fp_exp_-2_tl }   { { 1 } { 353352832 } { 366132692 } { -1 } }
\tl_const:cn { c_fp_exp_-3_tl }   { { 4 } { 978706836 } { 786394298 } { -2 } }
\tl_const:cn { c_fp_exp_-4_tl }   { { 1 } { 831563888 } { 873418029 } { -2 } }
\tl_const:cn { c_fp_exp_-5_tl }   { { 6 } { 737946999 } { 085467097 } { -3 } }
\tl_const:cn { c_fp_exp_-6_tl }   { { 2 } { 478752176 } { 666358423 } { -3 } }
\tl_const:cn { c_fp_exp_-7_tl }   { { 9 } { 118819655 } { 545162080 } { -4 } }
\tl_const:cn { c_fp_exp_-8_tl }   { { 3 } { 354626279 } { 025118388 } { -4 } }
\tl_const:cn { c_fp_exp_-9_tl }   { { 1 } { 234098040 } { 866795495 } { -4 } }
\tl_const:cn { c_fp_exp_-10_tl }  { { 4 } { 539992976 } { 248451536 } { -5 } }
\tl_const:cn { c_fp_exp_-20_tl }  { { 2 } { 061153622 } { 438557828 } { -9 } }
\tl_const:cn { c_fp_exp_-30_tl }  { { 9 } { 357622968 } { 840174605 } { -14 } }
\tl_const:cn { c_fp_exp_-40_tl }  { { 4 } { 248354255 } { 291588995 } { -18 } }
\tl_const:cn { c_fp_exp_-50_tl }  { { 1 } { 928749847 } { 963917783 } { -22 } }
\tl_const:cn { c_fp_exp_-60_tl }  { { 8 } { 756510762 } { 696520338 } { -27 } }
\tl_const:cn { c_fp_exp_-70_tl }  { { 3 } { 975449735 } { 908646808 } { -31 } }
\tl_const:cn { c_fp_exp_-80_tl }  { { 1 } { 804851387 } { 845415172 } { -35 } }
\tl_const:cn { c_fp_exp_-90_tl }  { { 8 } { 194012623 } { 990515430 } { -40 } }
\tl_const:cn { c_fp_exp_-100_tl } { { 3 } { 720075976 } { 020835963 } { -44 } }
\tl_const:cn { c_fp_exp_-200_tl } { { 1 } { 383896526 } { 736737530 } { -87 } }
\cs_new_protected_nopar:Npn \fp_exp:Nn  { \fp_exp_aux:NNn \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gexp:Nn { \fp_exp_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_exp:Nn  { c }
\cs_generate_variant:Nn \fp_gexp:Nn { c }
\cs_new_protected:Npn \fp_exp_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_split:Nn a {#3}
      \fp_standardise:NNNN
        \l_fp_input_a_sign_int
        \l_fp_input_a_integer_int
        \l_fp_input_a_decimal_int
        \l_fp_input_a_exponent_int
      \l_fp_input_a_extended_int \c_zero
      \tl_set:Nx \l_fp_arg_tl
        {
          \if_int_compare:w \l_fp_input_a_sign_int < \c_zero
            -
          \else:
            +
          \fi:
          \int_use:N \l_fp_input_a_integer_int
          .
          \exp_after:wN \use_none:n
            \int_value:w \int_eval:w
               \l_fp_input_a_decimal_int + \c_one_thousand_million
          e
          \int_use:N \l_fp_input_a_exponent_int
        }
      \if_cs_exist:w c_fp_exp ( \l_fp_arg_tl ) _fp \cs_end:
      \else:
        \exp_after:wN \fp_exp_internal:
      \fi:
      \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          #1 \exp_not:N #2
            {
              \if_cs_exist:w c_fp_exp ( \l_fp_arg_tl ) _fp
                \cs_end:
                \use:c { c_fp_exp ( \l_fp_arg_tl ) _fp }
              \else:
                \c_zero_fp
              \fi:
            }
        }
    \fp_tmp:w
  }
\cs_new_protected_nopar:Npn \fp_exp_internal:
  {
    \if_int_compare:w \l_fp_input_a_exponent_int < \c_three
      \fp_extended_normalise:
      \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
        \if_int_compare:w \l_fp_input_a_integer_int < 230 \scan_stop:
          \exp_after:wN \exp_after:wN \exp_after:wN
          \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \fp_exp_aux:
        \else:
          \exp_after:wN \exp_after:wN \exp_after:wN
          \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \fp_exp_overflow_msg:
          \fi:
      \else:
        \if_int_compare:w \l_fp_input_a_integer_int < 230 \scan_stop:
          \exp_after:wN \exp_after:wN \exp_after:wN
          \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN  \fp_exp_aux:
        \else:
          \fp_exp_const:cx { c_fp_exp ( \l_fp_arg_tl ) _fp }
            { \c_zero_fp }
        \fi:
      \fi:
    \else:
      \exp_after:wN \fp_exp_overflow_msg:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_exp_aux:
  {
    \if_int_compare:w \l_fp_input_a_integer_int > \c_zero
      \exp_after:wN \fp_exp_integer:
    \else:
      \l_fp_output_integer_int  \c_one
      \l_fp_output_decimal_int  \c_zero
      \l_fp_output_extended_int \c_zero
      \l_fp_output_exponent_int \c_zero
      \exp_after:wN \fp_exp_decimal:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_exp_integer:
  {
    \if_int_compare:w \l_fp_input_a_integer_int < \c_one_hundred
      \l_fp_exp_integer_int  \c_one
      \l_fp_exp_decimal_int  \c_zero
      \l_fp_exp_extended_int \c_zero
      \l_fp_exp_exponent_int \c_zero
      \exp_after:wN \fp_exp_integer_tens:
    \else:
      \tl_set:Nx \l_fp_internal_tl
        {
          \exp_after:wN \use_i:nnn
            \int_use:N \l_fp_input_a_integer_int
        }
      \l_fp_input_a_integer_int
        \int_eval:w
          \l_fp_input_a_integer_int - \l_fp_internal_tl 00
        \int_eval_end:
      \if_int_compare:w \l_fp_input_a_sign_int < \c_zero
        \if_int_compare:w \l_fp_output_integer_int > 200 \scan_stop:
          \fp_exp_const:cx { c_fp_exp ( \l_fp_arg_tl ) _fp }
            { \c_zero_fp }
        \else:
          \fp_exp_integer_const:n { - \l_fp_internal_tl 00 }
          \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \fp_exp_integer_tens:
        \fi:
      \else:
        \fp_exp_integer_const:n { \l_fp_internal_tl 00 }
        \exp_after:wN \exp_after:wN \exp_after:wN
          \exp_after:wN \fp_exp_integer_tens:
      \fi:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_exp_integer_tens:
  {
    \l_fp_output_integer_int  \l_fp_exp_integer_int
    \l_fp_output_decimal_int  \l_fp_exp_decimal_int
    \l_fp_output_extended_int \l_fp_exp_extended_int
    \l_fp_output_exponent_int \l_fp_exp_exponent_int
    \if_int_compare:w \l_fp_input_a_integer_int > \c_nine
      \tl_set:Nx \l_fp_internal_tl
        {
          \exp_after:wN \use_i:nn
            \int_use:N \l_fp_input_a_integer_int
        }
      \l_fp_input_a_integer_int
        \int_eval:w
          \l_fp_input_a_integer_int - \l_fp_internal_tl 0
        \int_eval_end:
      \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
        \fp_exp_integer_const:n { \l_fp_internal_tl 0 }
      \else:
        \fp_exp_integer_const:n { - \l_fp_internal_tl 0 }
      \fi:
      \fp_mul:NNNNNNNNN
        \l_fp_exp_integer_int \l_fp_exp_decimal_int \l_fp_exp_extended_int
        \l_fp_output_integer_int \l_fp_output_decimal_int
          \l_fp_output_extended_int
        \l_fp_output_integer_int \l_fp_output_decimal_int
          \l_fp_output_extended_int
      \tex_advance:D \l_fp_output_exponent_int \l_fp_exp_exponent_int
      \fp_extended_normalise_output:
    \fi:
    \fp_exp_integer_units:
  }
\cs_new_protected_nopar:Npn \fp_exp_integer_units:
  {
    \if_int_compare:w \l_fp_input_a_integer_int > \c_zero
      \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
        \fp_exp_integer_const:n { \int_use:N \l_fp_input_a_integer_int }
      \else:
        \fp_exp_integer_const:n
          { - \int_use:N \l_fp_input_a_integer_int }
      \fi:
      \fp_mul:NNNNNNNNN
        \l_fp_exp_integer_int \l_fp_exp_decimal_int \l_fp_exp_extended_int
        \l_fp_output_integer_int \l_fp_output_decimal_int
          \l_fp_output_extended_int
        \l_fp_output_integer_int \l_fp_output_decimal_int
          \l_fp_output_extended_int
      \tex_advance:D \l_fp_output_exponent_int \l_fp_exp_exponent_int
      \fp_extended_normalise_output:
    \fi:
    \fp_exp_decimal:
  }
\cs_new_protected:Npn \fp_exp_integer_const:n #1
  {
    \exp_after:wN \exp_after:wN \exp_after:wN
      \fp_exp_integer_const:nnnn
      \cs:w c_fp_exp_ #1 _tl \cs_end:
  }
\cs_new_protected:Npn \fp_exp_integer_const:nnnn #1#2#3#4
  {
    \l_fp_exp_integer_int  #1 \scan_stop:
    \l_fp_exp_decimal_int  #2 \scan_stop:
    \l_fp_exp_extended_int #3 \scan_stop:
    \l_fp_exp_exponent_int #4 \scan_stop:
  }
\cs_new_protected_nopar:Npn \fp_exp_decimal:
  {
    \if_int_compare:w \l_fp_input_a_decimal_int > \c_zero
      \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
        \l_fp_exp_integer_int  \c_one
        \l_fp_exp_decimal_int  \l_fp_input_a_decimal_int
        \l_fp_exp_extended_int \l_fp_input_a_extended_int
      \else:
        \l_fp_exp_integer_int \c_zero
        \if_int_compare:w \l_fp_exp_extended_int = \c_zero
          \l_fp_exp_decimal_int
            \int_eval:w
              \c_one_thousand_million - \l_fp_input_a_decimal_int
            \int_eval_end:
          \l_fp_exp_extended_int \c_zero
        \else:
          \l_fp_exp_decimal_int
            \int_eval:w
              999999999 - \l_fp_input_a_decimal_int
            \scan_stop:
          \l_fp_exp_extended_int
            \int_eval:w
              \c_one_thousand_million - \l_fp_input_a_extended_int
            \int_eval_end:
        \fi:
      \fi:
      \l_fp_input_b_sign_int     \l_fp_input_a_sign_int
      \l_fp_input_b_decimal_int  \l_fp_input_a_decimal_int
      \l_fp_input_b_extended_int \l_fp_input_a_extended_int
      \l_fp_count_int \c_one
      \fp_exp_Taylor:
      \fp_mul:NNNNNNNNN
        \l_fp_exp_integer_int \l_fp_exp_decimal_int \l_fp_exp_extended_int
        \l_fp_output_integer_int \l_fp_output_decimal_int
          \l_fp_output_extended_int
        \l_fp_output_integer_int \l_fp_output_decimal_int
          \l_fp_output_extended_int
    \fi:
    \if_int_compare:w \l_fp_output_extended_int < \c_five_hundred_million
    \else:
      \tex_advance:D \l_fp_output_decimal_int \c_one
      \if_int_compare:w \l_fp_output_decimal_int < \c_one_thousand_million
      \else:
        \l_fp_output_decimal_int \c_zero
        \tex_advance:D \l_fp_output_integer_int \c_one
      \fi:
    \fi:
    \fp_standardise:NNNN
      \l_fp_output_sign_int
      \l_fp_output_integer_int
      \l_fp_output_decimal_int
      \l_fp_output_exponent_int
    \fp_exp_const:cx { c_fp_exp ( \l_fp_arg_tl ) _fp }
      {
        +
        \int_use:N \l_fp_output_integer_int
        .
        \exp_after:wN \use_none:n
          \int_value:w \int_eval:w
             \l_fp_output_decimal_int + \c_one_thousand_million
        e
        \int_use:N \l_fp_output_exponent_int
      }
  }
\cs_new_protected_nopar:Npn \fp_exp_Taylor:
  {
    \tex_advance:D \l_fp_count_int \c_one
    \tex_multiply:D \l_fp_input_b_sign_int \l_fp_input_a_sign_int
    \fp_mul:NNNNNN
      \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
      \l_fp_input_b_decimal_int \l_fp_input_b_extended_int
      \l_fp_input_b_decimal_int \l_fp_input_b_extended_int
    \fp_div_integer:NNNNN
      \l_fp_input_b_decimal_int \l_fp_input_b_extended_int
      \l_fp_count_int
      \l_fp_input_b_decimal_int \l_fp_input_b_extended_int
    \if_int_compare:w
      \int_eval:w
        \l_fp_input_b_decimal_int + \l_fp_input_b_extended_int
        > \c_zero
      \if_int_compare:w \l_fp_input_b_sign_int > \c_zero
        \tex_advance:D \l_fp_exp_decimal_int \l_fp_input_b_decimal_int
        \tex_advance:D \l_fp_exp_extended_int
          \l_fp_input_b_extended_int
        \if_int_compare:w \l_fp_exp_extended_int < \c_one_thousand_million
      \else:
          \tex_advance:D \l_fp_exp_decimal_int \c_one
          \tex_advance:D \l_fp_exp_extended_int
            -\c_one_thousand_million
        \fi:
        \if_int_compare:w \l_fp_exp_decimal_int < \c_one_thousand_million
        \else:
          \tex_advance:D \l_fp_exp_integer_int \c_one
          \tex_advance:D \l_fp_exp_decimal_int
            -\c_one_thousand_million
        \fi:
      \else:
        \tex_advance:D \l_fp_exp_decimal_int -\l_fp_input_b_decimal_int
        \tex_advance:D \l_fp_exp_extended_int
          -\l_fp_input_a_extended_int
        \if_int_compare:w \l_fp_exp_extended_int < \c_zero
          \tex_advance:D \l_fp_exp_decimal_int \c_minus_one
          \tex_advance:D \l_fp_exp_extended_int \c_one_thousand_million
        \fi:
        \if_int_compare:w \l_fp_exp_decimal_int < \c_zero
          \tex_advance:D \l_fp_exp_integer_int \c_minus_one
          \tex_advance:D \l_fp_exp_decimal_int \c_one_thousand_million
        \fi:
      \fi:
      \exp_after:wN \fp_exp_Taylor:
    \fi:
  }
\cs_new_protected:Npn \fp_exp_const:Nx #1#2
  {
    \tl_new:N #1
    \tl_gset:Nx #1 {#2}
  }
\cs_generate_variant:Nn \fp_exp_const:Nx { c }
\tl_const:cn { c_fp_ln_10_1_tl } { { 2 } { 302585092 } { 994045684 } { 0 } }
\tl_const:cn { c_fp_ln_10_2_tl } { { 4 } { 605170185 } { 988091368 } { 0 } }
\tl_const:cn { c_fp_ln_10_3_tl } { { 6 } { 907755278 } { 982137052 } { 0 } }
\tl_const:cn { c_fp_ln_10_4_tl } { { 9 } { 210340371 } { 976182736 } { 0 } }
\tl_const:cn { c_fp_ln_10_5_tl } { { 1 } { 151292546 } { 497022842 } { 1 } }
\tl_const:cn { c_fp_ln_10_6_tl } { { 1 } { 381551055 } { 796427410 } { 1 } }
\tl_const:cn { c_fp_ln_10_7_tl } { { 1 } { 611809565 } { 095831979 } { 1 } }
\tl_const:cn { c_fp_ln_10_8_tl } { { 1 } { 842068074 } { 395226547 } { 1 } }
\tl_const:cn { c_fp_ln_10_9_tl } { { 2 } { 072326583 } { 694641116 } { 1 } }
\tl_const:cn { c_fp_ln_2_1_tl } { { 0 } { 693147180 } { 559945309 } { 0 } }
\tl_const:cn { c_fp_ln_2_2_tl } { { 1 } { 386294361 } { 119890618 } { 0 } }
\tl_const:cn { c_fp_ln_2_3_tl } { { 2 } { 079441541 } { 679835928 } { 0 } }
\cs_new_protected_nopar:Npn \fp_ln:Nn  { \fp_ln_aux:NNn \tl_set:Nn  }
\cs_new_protected_nopar:Npn \fp_gln:Nn { \fp_ln_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_ln:Nn  { c }
\cs_generate_variant:Nn \fp_gln:Nn { c }
\cs_new_protected:Npn \fp_ln_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_split:Nn a {#3}
      \fp_standardise:NNNN
        \l_fp_input_a_sign_int
        \l_fp_input_a_integer_int
        \l_fp_input_a_decimal_int
        \l_fp_input_a_exponent_int
      \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
        \if_int_compare:w
          \int_eval:w
            \l_fp_input_a_integer_int + \l_fp_input_a_decimal_int
            > \c_zero
          \exp_after:wN \exp_after:wN \exp_after:wN \fp_ln_aux:
        \else:
          \cs_set_protected:Npx \fp_tmp:w ##1##2
            {
              \group_end:
              ##1 \exp_not:N ##2 { \c_zero_fp }
            }
          \exp_after:wN \exp_after:wN \exp_after:wN \fp_ln_error_msg:
        \fi:
      \else:
        \cs_set_protected:Npx \fp_tmp:w ##1##2
          {
            \group_end:
            ##1 \exp_not:N ##2 { \c_zero_fp }
          }
        \exp_after:wN \fp_ln_error_msg:
      \fi:
    \fp_tmp:w #1 #2
  }
\cs_new_protected_nopar:Npn \fp_ln_aux:
  {
    \tl_set:Nx \l_fp_arg_tl
      {
        +
        \int_use:N \l_fp_input_a_integer_int
        .
        \exp_after:wN \use_none:n
          \int_value:w \int_eval:w
             \l_fp_input_a_decimal_int + \c_one_thousand_million
        e
        \int_use:N \l_fp_input_a_exponent_int
      }
    \if_cs_exist:w c_fp_ln ( \l_fp_arg_tl ) _fp \cs_end:
    \else:
      \exp_after:wN \fp_ln_exponent:
    \fi:
    \cs_set_protected:Npx \fp_tmp:w ##1##2
      {
        \group_end:
        ##1 \exp_not:N ##2
          { \use:c { c_fp_ln ( \l_fp_arg_tl ) _fp } }
      }
  }
\cs_new_protected_nopar:Npn \fp_ln_exponent:
  {
    \fp_ln_internal:
    \if_int_compare:w \l_fp_output_extended_int < \c_five_hundred_million
    \else:
      \tex_advance:D \l_fp_output_decimal_int \c_one
      \if_int_compare:w \l_fp_output_decimal_int < \c_one_thousand_million
      \else:
        \l_fp_output_decimal_int \c_zero
        \tex_advance:D \l_fp_output_integer_int \c_one
      \fi:
    \fi:
    \fp_standardise:NNNN
      \l_fp_output_sign_int
      \l_fp_output_integer_int
      \l_fp_output_decimal_int
      \l_fp_output_exponent_int
    \tl_const:cx { c_fp_ln ( \l_fp_arg_tl ) _fp }
      {
        \if_int_compare:w \l_fp_output_sign_int > \c_zero
          +
        \else:
          -
        \fi:
        \int_use:N \l_fp_output_integer_int
        .
        \exp_after:wN \use_none:n
          \int_value:w \int_eval:w
             \l_fp_output_decimal_int + \c_one_thousand_million
           \scan_stop:
        e
        \int_use:N \l_fp_output_exponent_int
      }
  }
\cs_new_protected_nopar:Npn \fp_ln_internal:
  {
    \if_int_compare:w \l_fp_input_a_exponent_int < \c_zero
      \l_fp_input_a_exponent_int -\l_fp_input_a_exponent_int
      \l_fp_output_sign_int \c_minus_one
    \else:
      \l_fp_output_sign_int \c_one
    \fi:
    \if_int_compare:w \l_fp_input_a_exponent_int > \c_nine
      \exp_after:wN \fp_ln_exponent_tens:NN
        \int_use:N \l_fp_input_a_exponent_int
    \else:
      \l_fp_output_integer_int  \c_zero
      \l_fp_output_decimal_int  \c_zero
      \l_fp_output_extended_int \c_zero
      \l_fp_output_exponent_int \c_zero
    \fi:
    \fp_ln_exponent_units:
  }
\cs_new_protected:Npn \fp_ln_exponent_tens:NN #1 #2
  {
    \l_fp_input_a_exponent_int #2 \scan_stop:
    \fp_ln_const:nn { 10 } { #1 }
    \tex_advance:D \l_fp_exp_exponent_int \c_one
    \l_fp_output_integer_int  \l_fp_exp_integer_int
    \l_fp_output_decimal_int  \l_fp_exp_decimal_int
    \l_fp_output_extended_int \l_fp_exp_extended_int
    \l_fp_output_exponent_int \l_fp_exp_exponent_int
  }
\cs_new_protected_nopar:Npn \fp_ln_exponent_units:
  {
    \if_int_compare:w \l_fp_input_a_exponent_int > \c_zero
      \fp_ln_const:nn { 10 } { \int_use:N \l_fp_input_a_exponent_int }
      \fp_ln_normalise:
      \fp_add:NNNNNNNNN
        \l_fp_exp_integer_int \l_fp_exp_decimal_int \l_fp_exp_extended_int
        \l_fp_output_integer_int \l_fp_output_decimal_int
          \l_fp_output_extended_int
        \l_fp_output_integer_int \l_fp_output_decimal_int
          \l_fp_output_extended_int
    \fi:
    \fp_ln_mantissa:
  }
\cs_new_protected_nopar:Npn \fp_ln_normalise:
  {
    \if_int_compare:w \l_fp_exp_exponent_int < \l_fp_output_exponent_int
      \tex_advance:D \l_fp_exp_decimal_int \c_one_thousand_million
      \exp_after:wN \use_i:nn \exp_after:wN
        \fp_ln_normalise_aux:NNNNNNNNN
        \int_use:N \l_fp_exp_decimal_int
       \exp_after:wN \fp_ln_normalise:
    \else:
      \l_fp_output_exponent_int \l_fp_exp_exponent_int
    \fi:
  }
\cs_new_protected:Npn \fp_ln_normalise_aux:NNNNNNNNN #1#2#3#4#5#6#7#8#9
  {
    \if_int_compare:w \l_fp_exp_integer_int = \c_zero
      \l_fp_exp_decimal_int #1#2#3#4#5#6#7#8 \scan_stop:
    \else:
      \tl_set:Nx \l_fp_internal_tl
        {
          \int_use:N \l_fp_exp_integer_int
          #1#2#3#4#5#6#7#8
        }
      \l_fp_exp_integer_int \c_zero
      \l_fp_exp_decimal_int \l_fp_internal_tl \scan_stop:
    \fi:
    \tex_divide:D \l_fp_exp_extended_int \c_ten
    \tl_set:Nx \l_fp_internal_tl
      {
        #9
        \int_use:N \l_fp_exp_extended_int
      }
    \l_fp_exp_extended_int \l_fp_internal_tl \scan_stop:
    \tex_advance:D \l_fp_exp_exponent_int \c_one
  }
\cs_new_protected_nopar:Npn \fp_ln_mantissa:
  {
    \l_fp_count_int \c_zero
    \l_fp_input_a_extended_int \c_zero
    \fp_ln_mantissa_aux:
    \if_int_compare:w \l_fp_count_int > \c_zero
      \fp_ln_const:nn { 2 } { \int_use:N \l_fp_count_int }
      \fp_ln_normalise:
      \if_int_compare:w \l_fp_output_sign_int > \c_zero
        \exp_after:wN \fp_add:NNNNNNNNN
      \else:
        \exp_after:wN \fp_sub:NNNNNNNNN
      \fi:
      \l_fp_output_integer_int \l_fp_output_decimal_int
        \l_fp_output_extended_int
      \l_fp_exp_integer_int \l_fp_exp_decimal_int \l_fp_exp_extended_int
      \l_fp_output_integer_int \l_fp_output_decimal_int
        \l_fp_output_extended_int
    \fi:
    \if_int_compare:w
      \int_eval:w
        \l_fp_input_a_integer_int + \l_fp_input_a_decimal_int > \c_one
      \exp_after:wN \fp_ln_Taylor:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_ln_mantissa_aux:
  {
    \if_int_compare:w \l_fp_input_a_integer_int > \c_one
      \tex_advance:D \l_fp_count_int \c_one
      \fp_ln_mantissa_divide_two:
      \exp_after:wN \fp_ln_mantissa_aux:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_ln_mantissa_divide_two:
  {
    \if_int_odd:w \l_fp_input_a_decimal_int
      \tex_advance:D \l_fp_input_a_extended_int \c_one_thousand_million
    \fi:
    \if_int_odd:w \l_fp_input_a_integer_int
      \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
    \fi:
    \tex_divide:D \l_fp_input_a_integer_int  \c_two
    \tex_divide:D \l_fp_input_a_decimal_int  \c_two
    \tex_divide:D \l_fp_input_a_extended_int \c_two
  }
\cs_new_protected:Npn \fp_ln_const:nn #1#2
  {
    \exp_after:wN \exp_after:wN \exp_after:wN
      \fp_exp_integer_const:nnnn
      \cs:w c_fp_ln_ #1 _ #2 _tl \cs_end:
  }
\cs_new_protected_nopar:Npn \fp_ln_Taylor:
  {
    \group_begin:
      \l_fp_input_a_integer_int \c_zero
      \l_fp_input_a_exponent_int \c_zero
      \l_fp_input_b_integer_int \c_two
      \l_fp_input_b_decimal_int \l_fp_input_a_decimal_int
      \l_fp_input_b_exponent_int \c_zero
      \fp_div_internal:
      \fp_ln_fixed:
      \l_fp_input_a_integer_int  \l_fp_output_integer_int
      \l_fp_input_a_decimal_int  \l_fp_output_decimal_int
      \l_fp_input_a_extended_int \c_zero
      \l_fp_input_a_exponent_int \l_fp_output_exponent_int
      \l_fp_output_decimal_int \c_zero %^^A Bug?
      \l_fp_output_decimal_int  \l_fp_input_a_decimal_int
      \l_fp_output_extended_int \l_fp_input_a_extended_int
      \fp_mul:NNNNNN
        \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
        \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
        \l_fp_input_b_decimal_int \l_fp_input_b_extended_int
      \l_fp_count_int \c_one
      \fp_ln_Taylor_aux:
      \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          \l_fp_exp_integer_int \c_zero
          \exp_not:N \l_fp_exp_decimal_int
            \int_use:N \l_fp_output_decimal_int \scan_stop:
          \exp_not:N \l_fp_exp_extended_int
            \int_use:N \l_fp_output_extended_int \scan_stop:
          \exp_not:N \l_fp_exp_exponent_int
            \int_use:N \l_fp_output_exponent_int \scan_stop:
        }
    \fp_tmp:w
    \tex_advance:D \l_fp_exp_decimal_int \l_fp_exp_decimal_int
    \if_int_compare:w \l_fp_exp_extended_int < \c_five_hundred_million
    \else:
      \tex_advance:D \l_fp_exp_extended_int -\c_five_hundred_million
      \tex_advance:D \l_fp_exp_decimal_int \c_one
    \fi:
    \tex_advance:D \l_fp_exp_extended_int \l_fp_exp_extended_int
    \fp_ln_normalise:
    \if_int_compare:w \l_fp_output_sign_int > \c_zero
      \exp_after:wN \fp_add:NNNNNNNNN
    \else:
      \exp_after:wN \fp_sub:NNNNNNNNN
    \fi:
    \l_fp_output_integer_int \l_fp_output_decimal_int
      \l_fp_output_extended_int
    \c_zero \l_fp_exp_decimal_int \l_fp_exp_extended_int
    \l_fp_output_integer_int \l_fp_output_decimal_int
      \l_fp_output_extended_int
  }
\cs_new_protected_nopar:Npn \fp_ln_fixed:
  {
    \if_int_compare:w \l_fp_output_exponent_int < \c_zero
      \tex_advance:D \l_fp_output_decimal_int \c_one_thousand_million
      \exp_after:wN \use_i:nn \exp_after:wN
        \fp_ln_fixed_aux:NNNNNNNNN
        \int_use:N \l_fp_output_decimal_int
       \exp_after:wN \fp_ln_fixed:
     \fi:
  }
\cs_new_protected:Npn \fp_ln_fixed_aux:NNNNNNNNN #1#2#3#4#5#6#7#8#9
  {
    \if_int_compare:w \l_fp_output_integer_int = \c_zero
      \l_fp_output_decimal_int #1#2#3#4#5#6#7#8 \scan_stop:
    \else:
      \tl_set:Nx \l_fp_internal_tl
        {
          \int_use:N \l_fp_output_integer_int
          #1#2#3#4#5#6#7#8
        }
      \l_fp_output_integer_int \c_zero
      \l_fp_output_decimal_int \l_fp_internal_tl \scan_stop:
    \fi:
    \tex_advance:D \l_fp_output_exponent_int \c_one
  }
\cs_new_protected_nopar:Npn \fp_ln_Taylor_aux:
  {
    \tex_advance:D \l_fp_count_int \c_two
    \fp_mul:NNNNNN
      \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
      \l_fp_input_b_decimal_int \l_fp_input_b_extended_int
      \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
    \if_int_compare:w
      \int_eval:w
        \l_fp_input_a_decimal_int + \l_fp_input_a_extended_int
        > \c_zero
      \fp_div_integer:NNNNN
        \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
        \l_fp_count_int
        \l_fp_exp_decimal_int \l_fp_exp_extended_int
        \tex_advance:D \l_fp_output_decimal_int \l_fp_exp_decimal_int
        \tex_advance:D \l_fp_output_extended_int \l_fp_exp_extended_int
        \if_int_compare:w \l_fp_output_extended_int < \c_one_thousand_million
        \else:
          \tex_advance:D \l_fp_output_decimal_int \c_one
          \tex_advance:D \l_fp_output_extended_int
            -\c_one_thousand_million
        \fi:
        \if_int_compare:w \l_fp_output_decimal_int < \c_one_thousand_million
        \else:
          \tex_advance:D \l_fp_output_integer_int \c_one
          \tex_advance:D \l_fp_output_decimal_int
            -\c_one_thousand_million
        \fi:
      \exp_after:wN \fp_ln_Taylor_aux:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_pow:Nn  { \fp_pow_aux:NNn \tl_set:Nn }
\cs_new_protected_nopar:Npn \fp_gpow:Nn { \fp_pow_aux:NNn \tl_gset:Nn }
\cs_generate_variant:Nn \fp_pow:Nn  { c }
\cs_generate_variant:Nn \fp_gpow:Nn { c }
\cs_new_protected:Npn \fp_pow_aux:NNn #1#2#3
  {
    \group_begin:
      \fp_read:N #2
      \l_fp_input_b_sign_int     \l_fp_input_a_sign_int
      \l_fp_input_b_integer_int  \l_fp_input_a_integer_int
      \l_fp_input_b_decimal_int  \l_fp_input_a_decimal_int
      \l_fp_input_b_exponent_int \l_fp_input_a_exponent_int
      \fp_split:Nn a {#3}
      \fp_standardise:NNNN
        \l_fp_input_a_sign_int
        \l_fp_input_a_integer_int
        \l_fp_input_a_decimal_int
        \l_fp_input_a_exponent_int
      \if_int_compare:w
        \int_eval:w
          \l_fp_input_b_integer_int + \l_fp_input_b_decimal_int
          = \c_zero
         \if_int_compare:w
           \int_eval:w
             \l_fp_input_a_integer_int + \l_fp_input_a_decimal_int
             = \c_zero
             \cs_set_protected:Npx \fp_tmp:w ##1##2
               {
                 \group_end:
                 ##1 ##2 { \c_undefined_fp }
               }
           \else:
             \cs_set_protected:Npx \fp_tmp:w ##1##2
               {
                 \group_end:
                 ##1 ##2 { \c_zero_fp }
               }
          \fi:
       \else:
         \if_int_compare:w
           \int_eval:w
             \l_fp_input_a_integer_int + \l_fp_input_a_decimal_int
             = \c_zero
             \cs_set_protected:Npx \fp_tmp:w ##1##2
               {
                 \group_end:
                 ##1 ##2 { \c_one_fp }
               }
           \else:
             \exp_after:wN \exp_after:wN \exp_after:wN
               \fp_pow_aux_i:
          \fi:
       \fi:
    \fp_tmp:w #1 #2
}
\cs_new_protected_nopar:Npn \fp_pow_aux_i:
  {
    \if_int_compare:w \l_fp_input_b_sign_int > \c_zero
      \tl_set:Nn \l_fp_sign_tl { + }
      \exp_after:wN \fp_pow_aux_ii:
    \else:
      \l_fp_input_a_extended_int \c_zero
      \if_int_compare:w \l_fp_input_a_exponent_int < \c_ten
        \group_begin:
        \fp_extended_normalise:
        \if_int_compare:w
          \int_eval:w
            \l_fp_input_a_decimal_int + \l_fp_input_a_extended_int
            = \c_zero
           \group_end:
          \tl_set:Nn \l_fp_sign_tl { - }
          \exp_after:wN \exp_after:wN \exp_after:wN
          \exp_after:wN \exp_after:wN \exp_after:wN
          \exp_after:wN \fp_pow_aux_ii:
        \else:
          \group_end:
          \cs_set_protected:Npx \fp_tmp:w ##1##2
            {
              \group_end:
              ##1 ##2 { \c_undefined_fp }
           }
        \fi:
      \else:
        \cs_set_protected:Npx \fp_tmp:w ##1##2
          {
            \group_end:
            ##1 ##2 { \c_undefined_fp }
         }
      \fi:
    \fi:
  }
\cs_new_protected_nopar:Npn \fp_pow_aux_ii:
  {
    \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
      \exp_after:wN \fp_pow_aux_iv:
    \else:
      \if_int_compare:w \l_fp_input_a_exponent_int < \c_ten
        \group_begin:
        \l_fp_input_a_extended_int \c_zero
        \fp_extended_normalise:
        \if_int_compare:w \l_fp_input_a_decimal_int = \c_zero
          \if_int_compare:w \l_fp_input_a_integer_int > \c_ten
            \group_end:
            \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \exp_after:wN \exp_after:wN
              \fp_pow_aux_iv:
          \else:
            \group_end:
            \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \exp_after:wN \exp_after:wN
              \exp_after:wN \fp_pow_aux_iii:
          \fi:
        \else:
          \group_end:
            \exp_after:wN \exp_after:wN \exp_after:wN
            \exp_after:wN \exp_after:wN \exp_after:wN
              \exp_after:wN \fp_pow_aux_iv:
        \fi:
      \else:
        \exp_after:wN \exp_after:wN \exp_after:wN
          \fp_pow_aux_iv:
      \fi:
    \fi:
    \cs_set_protected:Npx \fp_tmp:w ##1##2
      {
        \group_end:
        ##1 ##2
          {
            \l_fp_sign_tl
            \int_use:N \l_fp_output_integer_int
            .
            \exp_after:wN \use_none:n
              \int_value:w \int_eval:w
                 \l_fp_output_decimal_int + \c_one_thousand_million
            e
            \int_use:N \l_fp_output_exponent_int
          }
      }
  }
\cs_new_protected_nopar:Npn \fp_pow_aux_iii:
  {
    \l_fp_input_a_sign_int \c_one
    \fp_pow_aux_iv:
    \l_fp_input_a_integer_int  \c_one
    \l_fp_input_a_decimal_int  \c_zero
    \l_fp_input_a_exponent_int \c_zero
    \l_fp_input_b_integer_int  \l_fp_output_integer_int
    \l_fp_input_b_decimal_int  \l_fp_output_decimal_int
    \l_fp_input_b_exponent_int \l_fp_output_exponent_int
    \fp_div_internal:
  }
\cs_new_protected_nopar:Npn \fp_pow_aux_iv:
  {
    \group_begin:
      \l_fp_input_a_integer_int  \l_fp_input_b_integer_int
      \l_fp_input_a_decimal_int  \l_fp_input_b_decimal_int
      \l_fp_input_a_exponent_int \l_fp_input_b_exponent_int
      \fp_ln_internal:
      \cs_set_protected_nopar:Npx \fp_tmp:w
        {
          \group_end:
          \exp_not:N \l_fp_input_b_sign_int
            \int_use:N \l_fp_output_sign_int \scan_stop:
          \exp_not:N \l_fp_input_b_integer_int
            \int_use:N \l_fp_output_integer_int \scan_stop:
          \exp_not:N \l_fp_input_b_decimal_int
            \int_use:N \l_fp_output_decimal_int \scan_stop:
          \exp_not:N \l_fp_input_b_extended_int
            \int_use:N \l_fp_output_extended_int \scan_stop:
          \exp_not:N \l_fp_input_b_exponent_int
            \int_use:N \l_fp_output_exponent_int \scan_stop:
        }
    \fp_tmp:w
    \l_fp_input_a_extended_int  \c_zero
    \fp_mul:NNNNNNNNN
      \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
        \l_fp_input_a_extended_int
      \l_fp_input_b_integer_int \l_fp_input_b_decimal_int
        \l_fp_input_b_extended_int
      \l_fp_output_integer_int \l_fp_output_decimal_int
        \l_fp_output_extended_int
    \l_fp_output_exponent_int
      \int_eval:w
        \l_fp_input_a_exponent_int + \l_fp_input_b_exponent_int
      \scan_stop:
    \fp_extended_normalise_output:
    \tex_multiply:D \l_fp_input_a_sign_int \l_fp_input_b_sign_int
    \l_fp_input_a_integer_int  \l_fp_output_integer_int
    \l_fp_input_a_decimal_int  \l_fp_output_decimal_int
    \l_fp_input_a_extended_int \l_fp_output_extended_int
    \l_fp_input_a_exponent_int \l_fp_output_exponent_int
    \l_fp_output_integer_int  \c_zero
    \l_fp_output_decimal_int  \c_zero
    \l_fp_output_extended_int \c_zero
    \l_fp_output_exponent_int \c_zero
    \cs_set_eq:NN \fp_exp_const:Nx \use_none:nn
    \fp_exp_internal:
  }
\prg_new_conditional:Npnn \fp_if_undefined:N #1 { p , T , F , TF }
  {
    \if_meaning:w #1 \c_undefined_fp
      \prg_return_true:
    \else:
      \prg_return_false:
    \fi:
  }
\prg_new_conditional:Npnn \fp_if_zero:N #1 { p , T , F , TF }
  {
    \if_meaning:w #1 \c_zero_fp
      \prg_return_true:
    \else:
      \prg_return_false:
    \fi:
  }
\prg_new_protected_conditional:Npnn \fp_compare:nNn #1#2#3 { T , F , TF }
  {
    \group_begin:
      \fp_split:Nn a {#1}
      \fp_standardise:NNNN
        \l_fp_input_a_sign_int
        \l_fp_input_a_integer_int
        \l_fp_input_a_decimal_int
        \l_fp_input_a_exponent_int
      \fp_split:Nn b {#3}
      \fp_standardise:NNNN
        \l_fp_input_b_sign_int
        \l_fp_input_b_integer_int
        \l_fp_input_b_decimal_int
        \l_fp_input_b_exponent_int
      \fp_compare_aux:N #2
  }
\prg_new_protected_conditional:Npnn \fp_compare:NNN #1#2#3 { T , F , TF }
  {
    \group_begin:
      \fp_read:N #3
      \l_fp_input_b_sign_int     \l_fp_input_a_sign_int
      \l_fp_input_b_integer_int  \l_fp_input_a_integer_int
      \l_fp_input_b_decimal_int  \l_fp_input_a_decimal_int
      \l_fp_input_b_exponent_int \l_fp_input_a_exponent_int
      \fp_read:N #1
      \fp_compare_aux:N #2
  }
\cs_new_protected:Npn \fp_compare_aux:N #1
  {
    \cs_if_exist:cTF { fp_compare_#1: }
      { \use:c { fp_compare_#1: } }
      {
        \group_end:
        \prg_return_false:
      }
  }
\cs_new_protected_nopar:cpn { fp_compare_=: }
  {
    \if_int_compare:w \l_fp_input_a_sign_int = \l_fp_input_b_sign_int
      \if_int_compare:w \l_fp_input_a_integer_int = \l_fp_input_b_integer_int
        \if_int_compare:w \l_fp_input_a_decimal_int = \l_fp_input_b_decimal_int
          \if_int_compare:w
            \l_fp_input_a_exponent_int = \l_fp_input_b_exponent_int
            \group_end:
            \prg_return_true:
          \else:
            \group_end:
            \prg_return_false:
          \fi:
        \else:
          \group_end:
          \prg_return_false:
        \fi:
      \else:
        \group_end:
        \prg_return_false:
      \fi:
    \else:
      \group_end:
      \prg_return_false:
    \fi:
  }
\cs_new_protected_nopar:cpn { fp_compare_>: }
  {
    \if_int_compare:w \int_eval:w
      \l_fp_input_a_integer_int + \l_fp_input_a_decimal_int
      = \c_zero
      \if_int_compare:w \int_eval:w
        \l_fp_input_b_integer_int + \l_fp_input_b_decimal_int
        = \c_zero
        \group_end:
        \prg_return_false:
      \else:
        \if_int_compare:w \l_fp_input_b_sign_int > \c_zero
          \group_end:
          \prg_return_false:
        \else:
          \group_end:
          \prg_return_true:
        \fi:
      \fi:
    \else:
      \if_int_compare:w \int_eval:w
        \l_fp_input_b_integer_int + \l_fp_input_b_decimal_int
        = \c_zero
        \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
          \group_end:
          \prg_return_true:
        \else:
          \group_end:
          \prg_return_false:
        \fi:
      \else:
        \use:c { fp_compare_>_aux: }
      \fi:
    \fi:
  }
\cs_new_protected_nopar:cpn { fp_compare_>_aux: }
  {
    \if_int_compare:w \l_fp_input_a_sign_int > \l_fp_input_b_sign_int
      \group_end:
      \prg_return_true:
    \else:
      \if_int_compare:w \l_fp_input_a_sign_int < \l_fp_input_b_sign_int
        \group_end:
        \prg_return_false:
      \else:
        \if_int_compare:w \l_fp_input_a_sign_int > \c_zero
          \use:c { fp_compare_absolute_a>b: }
        \else:
          \use:c { fp_compare_absolute_a<b: }
        \fi:
      \fi:
    \fi:
  }
\cs_new_protected_nopar:cpn { fp_compare_absolute_a>b: }
  {
    \if_int_compare:w \l_fp_input_a_exponent_int > \l_fp_input_b_exponent_int
      \group_end:
      \prg_return_true:
    \else:
      \if_int_compare:w \l_fp_input_a_exponent_int < \l_fp_input_b_exponent_int
        \group_end:
        \prg_return_false:
      \else:
        \if_int_compare:w \l_fp_input_a_integer_int > \l_fp_input_b_integer_int
          \group_end:
          \prg_return_true:
        \else:
          \if_int_compare:w
            \l_fp_input_a_integer_int < \l_fp_input_b_integer_int
            \group_end:
            \prg_return_false:
          \else:
            \if_int_compare:w
              \l_fp_input_a_decimal_int > \l_fp_input_b_decimal_int
              \group_end:
              \prg_return_true:
            \else:
              \group_end:
              \prg_return_false:
            \fi:
          \fi:
        \fi:
      \fi:
    \fi:
  }
\cs_new_protected_nopar:cpn { fp_compare_absolute_a<b: }
  {
    \if_int_compare:w \l_fp_input_b_exponent_int > \l_fp_input_a_exponent_int
      \group_end:
      \prg_return_true:
    \else:
      \if_int_compare:w \l_fp_input_b_exponent_int < \l_fp_input_a_exponent_int
        \group_end:
        \prg_return_false:
      \else:
        \if_int_compare:w \l_fp_input_b_integer_int > \l_fp_input_a_integer_int
          \group_end:
          \prg_return_true:
        \else:
          \if_int_compare:w
            \l_fp_input_b_integer_int < \l_fp_input_a_integer_int
            \group_end:
            \prg_return_false:
          \else:
            \if_int_compare:w
              \l_fp_input_b_decimal_int > \l_fp_input_a_decimal_int
              \group_end:
              \prg_return_true:
            \else:
              \group_end:
              \prg_return_false:
            \fi:
          \fi:
        \fi:
      \fi:
    \fi:
  }
\cs_new_protected_nopar:cpn { fp_compare_<: }
  {
    \tl_set:Nx \l_fp_internal_tl
      {
        \int_set:Nn \exp_not:N \l_fp_input_a_sign_int
          { \int_use:N \l_fp_input_b_sign_int }
        \int_set:Nn \exp_not:N \l_fp_input_a_integer_int
          { \int_use:N \l_fp_input_b_integer_int }
        \int_set:Nn \exp_not:N \l_fp_input_a_decimal_int
          { \int_use:N \l_fp_input_b_decimal_int }
        \int_set:Nn \exp_not:N \l_fp_input_a_exponent_int
          { \int_use:N \l_fp_input_b_exponent_int }
        \int_set:Nn \exp_not:N \l_fp_input_b_sign_int
          { \int_use:N \l_fp_input_a_sign_int }
        \int_set:Nn \exp_not:N \l_fp_input_b_integer_int
          { \int_use:N \l_fp_input_a_integer_int }
        \int_set:Nn \exp_not:N \l_fp_input_b_decimal_int
          { \int_use:N \l_fp_input_a_decimal_int }
        \int_set:Nn \exp_not:N \l_fp_input_b_exponent_int
          { \int_use:N \l_fp_input_a_exponent_int }
      }
    \l_fp_internal_tl
    \use:c { fp_compare_>: }
  }
\prg_new_protected_conditional:Npnn \fp_compare:n #1 { T , F , TF }
  {
    \group_begin:
      \tl_set:Nx \l_fp_internal_tl
        {
          \group_end:
          \fp_compare_aux_i:w #1 \exp_not:n { == \q_nil == \q_stop }
        }
     \l_fp_internal_tl
  }
\cs_new_protected:Npn \fp_compare_aux_i:w #1 == #2 == #3 \q_stop
  {
    \quark_if_nil:nTF {#2}
      { \fp_compare_aux_ii:w #1 != \q_nil != \q_stop }
      { \fp_compare:nNnTF {#1} = {#2} \prg_return_true: \prg_return_false: }
  }
\cs_new_protected:Npn \fp_compare_aux_ii:w #1 != #2 != #3 \q_stop
  {
    \quark_if_nil:nTF {#2}
      { \fp_compare_aux_iii:w #1 <= \q_nil <= \q_stop }
      { \fp_compare:nNnTF {#1} = {#2} \prg_return_false: \prg_return_true: }
  }
\cs_new_protected:Npn \fp_compare_aux_iii:w #1 <= #2 <= #3 \q_stop
  {
    \quark_if_nil:nTF {#2}
      { \fp_compare_aux_iv:w #1 >= \q_nil >= \q_stop }
      { \fp_compare:nNnTF {#1} > {#2} \prg_return_false: \prg_return_true: }
  }
\cs_new_protected:Npn \fp_compare_aux_iv:w #1 >= #2 >= #3 \q_stop
  {
    \quark_if_nil:nTF {#2}
      { \fp_compare_aux_v:w #1 = \q_nil  \q_stop }
      { \fp_compare:nNnTF {#1} < {#2} \prg_return_false: \prg_return_true: }
  }
\cs_new_protected:Npn \fp_compare_aux_v:w #1 = #2 = #3 \q_stop
  {
    \quark_if_nil:nTF {#2}
      { \fp_compare_aux_vi:w #1 < \q_nil < \q_stop }
      { \fp_compare:nNnTF {#1} = {#2} \prg_return_true: \prg_return_false: }
  }
\cs_new_protected:Npn \fp_compare_aux_vi:w #1 < #2 < #3 \q_stop
  {
    \quark_if_nil:nTF {#2}
      { \fp_compare_aux_vii:w #1 > \q_nil > \q_stop }
      { \fp_compare:nNnTF {#1} < {#2} \prg_return_true: \prg_return_false: }
  }
\cs_new_protected:Npn \fp_compare_aux_vii:w #1 > #2 > #3 \q_stop
  {
    \quark_if_nil:nTF {#2}
      { \prg_return_false: }
      { \fp_compare:nNnTF {#1} > {#2} \prg_return_true: \prg_return_false: }
  }
\msg_kernel_new:nnnn { fpu } { overflow }
  { Number~too~big. }
  {
    The~input~given~is~too~big~for~the~LaTeX~floating~point~unit. \\
    Further~errors~may~well~occur!
  }
\cs_new_protected_nopar:Npn \fp_overflow_msg:
  { \msg_kernel_error:nn { fpu } { overflow } }
\msg_kernel_new:nnnn { fpu } { exponent-overflow }
  { Number~too~big~for~exponent~unit. }
  {
    The~exponent~of~the~input~given~is~too~big~for~the~floating~point~
    unit:~the~maximum~input~value~for~an~exponent~is~230.
  }
\cs_new_protected_nopar:Npn \fp_exp_overflow_msg:
  { \msg_kernel_error:nn { fpu } { exponent-overflow } }
\msg_kernel_new:nnnn { fpu } { logarithm-input-error }
  { Invalid~input~to~ln~function. }
  { Logarithms~can~only~be~calculated~for~positive~numbers. }
\cs_new_protected_nopar:Npn \fp_ln_error_msg: {
  \msg_kernel_error:nn { fpu } { logarithm-input-error }
}
\msg_kernel_new:nnnn { fpu } { trigonometric-overflow }
  { Number~too~big~for~trigonometry~unit. }
  {
    The~trigonometry~code~can~only~work~with~numbers~smaller~
    than~1000000000.
  }
\cs_new_protected_nopar:Npn \fp_trig_overflow_msg:
  { \msg_kernel_error:nn { fpu } { trigonometric-overflow } }
%% 
%%
%% End of file `l3fp.sty'.
