txt: ## printf.md
  printf
  
  Combined from primary sources listed below.
  
  # [In IO::Handle](#___top "go to top of document")[§](#(IO::Handle)_method_printf "direct link")
  
  See primary documentation
  [in context](/type/IO/Handle#method_printf)
  for **method printf**.
  
  ```raku
  multi method printf(IO::Handle:D: Cool $format, *@args)
  ```
  
  Formats a string based on the given format and arguments and `.print`s the result into the filehandle. See [sprintf](/routine/sprintf) for details on acceptable format directives.
  
  Attempting to call this method when the handle is [in binary mode](/type/IO/Handle#method_encoding) will result in [`X::IO::BinaryMode`](/type/X/IO/BinaryMode) exception being thrown.
  
  ```raku
  my $fh = open 'path/to/file', :w;
  $fh.printf: "The value is %d\n", 32;
  $fh.close;
  
  ```
  
  # [In Independent routines](#___top "go to top of document")[§](#(Independent_routines)_routine_printf "direct link")
  
  See primary documentation
  [in context](/type/independent-routines#routine_printf)
  for **routine printf**.
  
  ```raku
  multi printf(Cool:D $format, *@args)
  ```
  
  Produces output according to a format. The format used is the invocant (if called in method form) or the first argument (if called as a routine). The rest of the arguments will be substituted in the format following the format conventions. See [sprintf](/routine/sprintf) for details on acceptable format directives.
  
  ```raku
  "%s is %s".printf("þor", "mighty");    # OUTPUT: «þor is mighty»
  printf( "%s is %s", "þor", "mighty");  # OUTPUT: «þor is mighty»
  ```
  
  On [`Junction`](/type/Junction)s, it will also autothread, without a guaranteed order.
  
  ```raku
  printf( "%.2f ", ⅓ | ¼ | ¾ ); # OUTPUT: «0.33 0.25 0.75 »
  ```
  
  # [In Cool](#___top "go to top of document")[§](#(Cool)_method_printf "direct link")
  
  See primary documentation
  [in context](/type/Cool#method_printf)
  for **method printf**.
  
  ```raku
  method printf(*@args)
  ```
  
  Uses the object, as long as it is a [format string](/type/independent-routines#Directives), to format and print the arguments
  
  ```raku
  "%.8f".printf(now - now ); # OUTPUT: «-0.00004118»
  
  ```
  