### ----------------------------------------------------
### -- Gzz::Text::Utils
### -- Licenses: LGPL-3.0-or-later
### -- Authors: Francis Grizzly Smit <grizzly@smit.id.au>
### -- File: rakulib/Gzz/Text/Utils.rakumod
### ----------------------------------------------------
### -- Chunk 5 of 8
spec-char;
                                             if $type-prefix {
                                                 $result ~= right('0'~ $spec-char ~ sprintf($fmt, $width - 2, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $result ~= right(sprintf($fmt, $width, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         }
                                     } else {
                                         if $precision >= 0 {
                                             $fmt ~= '.*';
                                             $fmt ~= $spec-char;
                                             if $type-prefix {
                                                 $result ~= right('0'~ $spec-char ~ sprintf($fmt, $precision - 2, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $result ~= right(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         } else {
                                             $fmt ~= $spec-char;
                                             $result ~= right(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             if $type-prefix {
                                                 $result ~= right('0'~ $spec-char ~ sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $result ~= right(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         }
                                     }
                                 } elsif $padding eq ' ' {
                                     $fmt ~= '#' if $type-prefix;
                                     $fmt ~= '0';
                                     if $justify eq '^' {
                                         if $width >= 0 {
                                             if $precision >= 0 {
                                                 $fmt ~= '.*';
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         } else { # $width < 0 #
                                             if $precision >= 0 {
                                                 $fmt ~= '.*';
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         } # $width < 0 #
                                     } else { # justify is either '-' or '' i.e. left or right #
                                         if $precision >= 0 {
                                             $fmt ~= '.*';
                                             $fmt ~= $spec-char;
                                             if $justify eq '-' {
                                                 $result ~= left(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $result ~= right(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         } else {
                                             $fmt ~= $spec-char;
                                             if $justify eq '-' {
                                                 $result ~= left(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $result ~= right(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         }
                                     } # justify is either '-' or '' i.e. left or right #
                                 } elsif $padding eq '' { # $padding eq '' #
                                     $fmt ~= '#' if $type-prefix;
                                     if $justify eq '^' {
                                         if $width >= 0 {
                                             if $precision >= 0 {
                                                 $fmt ~= '.*';
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $precision, $arg), $width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $arg), $width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         } else { # $width < 0 #
                                             if $precision >= 0 {
                                                 $fmt ~= '.*';
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $precision, $arg), $precision,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $arg), $max-width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         } # $width < 0 #
                                     } else { # justify is either '-' or '' i.e. left or right #
                                         if $precision >= 0 {
                                             $fmt ~= '.*';
                                             $fmt ~= $spec-char;
                                             if $justify eq '-' {
                                                 $result ~= left(sprintf($fmt, $precision, $arg), $width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $result ~= right(sprintf($fmt, $precision, $arg), $width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         } else {
                                             $fmt ~= $spec-char;
                                             if $justify eq '-' {
                                                 $result ~= left(sprintf($fmt, $arg), $width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $result ~= right(sprintf($fmt, $arg), $width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         }
                                     } # justify is either '-' or '' i.e. left or right #
                                 } else { # $padding eq something-else #
                                     $fmt ~= '#' if $type-prefix;
                                     if $justify eq '^' {
                                         if $width >= 0 {
                                             if $precision >= 0 {
                                                 $fmt ~= '.*';
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         } else { # $width < 0 #
                                             if $precision >= 0 {
                                                 $fmt ~= '.*';
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $fmt ~= $spec-char;
                                                 $result ~= centre(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         } # $width < 0 #
                                     } else { # justify is either '-' or '' i.e. left or right #
                                         if $precision >= 0 {
                                             $fmt ~= '.*';
                                             $fmt ~= $spec-char;
                                             if $justify eq '-' {
                                                 $result ~= left(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $result ~= right(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         } else {
                                             $fmt ~= $spec-char;
                                             if $justify eq '-' {
                                                 $result ~= left(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             } else {
                                                 $result ~= right(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                             }
                                         }
                                     } # justify is either '-' or '' i.e. left or right #
                                 }
                             } # when 'x', 'X' #
                when 'e'|'E' {
                                  $arg .=Num;
                                  $max-width = max($max-width, $width, 0) if $max-width > 0; #`« should not really have a both for this
                                                                                                 so munge together.
                                                                                                 Traditionally sprintf etc treat precision
                                                                                                 as max-width for Ints. »
                                  my Str:D $fmt = '%';
                                  $fmt ~= '+' if $force-sign;
                                  $fmt ~= 'v' if $vector;
                                  $fmt ~= '#' if $type-prefix;
                                  ##########################################################
                                  #                                                        #
                                  #   centring makes no sense here  so we will not do it   #
                                  #                                                        #
                                  ##########################################################
                                  if $padding eq '0' {
                                      $fmt ~= '-' if $justify eq '-';
                                      $fmt ~= $padding;
                                      if $width >= 0 { # centre etc make no sense here #
                                          if $precision >= 0 {
                                              $fmt ~= '*.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= '*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          }
                                      } else { # $width < 0 #
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          }
                                      }
                                  } elsif $padding eq ' ' {
                                      if $width >= 0 { 
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          } else {
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          }
                                      } else { # $width < 0 #
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          } else {
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          }
                                      }
                                  } elsif $padding eq '' {
                                      $fmt ~= '-' if $justify eq '-';
                                      $fmt ~= $padding;
                                      if $width >= 0 { # centre etc make no sense here #
                                          if $precision >= 0 {
                                              $fmt ~= '*.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $precision, $arg), $width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= '*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $arg), $width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          }
                                      } else { # $width < 0 #
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $precision, $arg), $precision,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $arg), $max-width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          }
                                      }
                                  } else { # $padding eq something-else #
                                      if $width >= 0 { # centre etc make sense  here #
                                          if $precision >= 0 {
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else { # right justification #
                                                  $result ~= right(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          } else { # $precision < 0 #
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else { # right justification #
                                                  $result ~= right(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          }
                                      } else { # $width < 0 #
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          } else {
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          }
                                      }
                                  }
                             } # when 'e', 'E' #
                when 'f'|'F' {
                                  $arg .=Num;
                                  $max-width = max($max-width, $width, 0) if $max-width > 0; #`« should not really have a both for this
                                                                                                 so munge together.
                                                                                                 Traditionally sprintf etc treat precision
                                                                                                 as max-width for Ints. »
                                  my Str:D $fmt = '%';
                                  $fmt ~= '+' if $force-sign;
                                  $fmt ~= 'v' if $vector;
                                  $fmt ~= '#' if $type-prefix;
                                  dd $arg, $fmt, $width, $precision, $max-width, $padding, $justify, $type-prefix if $debug;
                                  ##########################################################
                                  #                                                        #
                                  #   centring makes no sense here  so we will not do it   #
                                  #                                                        #
                                  ##########################################################
                                  if $padding eq '0' {
                                      $fmt ~= '-' if $justify eq '-';
                                      $fmt ~= $padding;
                                      if $width >= 0 { # centre etc make no sense here #
                                          if $precision >= 0 {
                                              $fmt ~= '*.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= '*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          }
                                      } else { # $width < 0 #
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $precision, $arg), $precision, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          }
                                      }
                                  } elsif $padding eq ' ' || $padding eq '' {
                                      if $width >= 0 { 
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          } else {
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          }
                                      } else { # $width < 0 #
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $precision, $arg), $precision, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $precision, $arg), $precision, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $precision, $arg), $precision, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          } else {
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          }
                                      }
                                  } elsif $padding eq '' {
                                      $fmt ~= '-' if $justify eq '-';
                                      $fmt ~= $padding;
                                      if $width >= 0 { # centre etc make no sense here #
                                          if $precision >= 0 {
                                              $fmt ~= '*.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= '*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          }
                                      } else { # $width < 0 #
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $precision, $arg), $precision, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          }
                                      }
                                  } else { # $padding eq something-else #
                                      if $width >= 0 { 
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          } else {
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          }
                                      } else { # $width < 0 #
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          } else {
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          }
                                      }
                                  }
                             } # when 'f', 'F' #
                when 'g'|'G' {
                                  $arg .=Num;
                                  $max-width = max($max-width, $width, 0) if $max-width > 0; #`« should not really have a both for this
                                                                                                 so munge together.
                                                                                                 Traditionally sprintf etc treat precision
                                                                                                 as max-width for Ints. »
                                  my Str:D $fmt = '%';
                                  $fmt ~= '+' if $force-sign;
                                  $fmt ~= 'v' if $vector;
                                  $fmt ~= '#' if $type-prefix;
                                  ##########################################################
                                  #                                                        #
                                  #   centring makes no sense here  so we will not do it   #
                                  #                                                        #
                                  ##########################################################
                                  if $padding eq '0' {
                                      $fmt ~= '-' if $justify eq '-';
                                      $fmt ~= $padding;
                                      if $width >= 0 { # centre etc make no sense here #
                                          if $precision >= 0 {
                                              $fmt ~= '*.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= '*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          }
                                      } else { # $width < 0 #
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $precision, $arg), $precision, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          }
                                      }
                                  } elsif $padding eq ' ' {
                                      if $width >= 0 { 
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $precision, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          } else {
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $arg), $width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          }
                                      } else { # $width < 0 #
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $precision, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          } else {
                                              $fmt ~= $spec-char;
                                              if $justify eq '^' {
                                                  $result ~= centre(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } elsif $justify eq '-' {
                                                  $result ~= left(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              } else {
                                                  $result ~= right(sprintf($fmt, $arg), $max-width, $padding,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                              }
                                          }
                                      }
                                  } elsif $padding eq '' {
                                      $fmt ~= '-' if $justify eq '-';
                                      $fmt ~= $padding;
                                      if $width >= 0 { # centre etc make no sense here #
                                          if $precision >= 0 {
                                              $fmt ~= '*.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $precision, $arg), $width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= '*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $width, $arg), $width,
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          }
                                      } else { # $width < 0 #
                                          if $precision >= 0 {
                                              $fmt ~= '.*';
                                              $fmt ~= $spec-char;
                                              $result ~= right(sprintf($fmt, $precision, $arg), $width, 
                                                                               :number-of-chars(&internal-number-of-chars),
                                                                                                                   :$max-width, :$ellipsis);
                                          } else {
                                              $fmt ~= $spec