]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Second argument to Utilities::int_to_string can now be omitted, leading to no padding...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 3 Aug 2006 00:34:29 +0000 (00:34 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 3 Aug 2006 00:34:29 +0000 (00:34 +0000)
git-svn-id: https://svn.dealii.org/trunk@13580 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/utilities.h
deal.II/base/source/utilities.cc
deal.II/doc/news/changes.html
tests/base/utilities_01.cc
tests/base/utilities_01/cmp/generic

index aaec1d9c4257107e1c3f203c8ab2ea0ee81353b9..791ab2f51bc60940fb6994758722fef68853b046 100644 (file)
@@ -43,7 +43,7 @@ namespace Utilities
                                     */
   std::string
   int_to_string (const unsigned int i,
-                const unsigned int digits);
+                const unsigned int digits = deal_II_numbers::invalid_unsigned_int);
 
                                    /**
                                     * Determine how many digits are needed to
index 310d5106e4c7610d5175540b1a9f336527eb83af..c59741c668dd9411ada17888fab5e519a49e173c 100644 (file)
@@ -54,6 +54,12 @@ namespace Utilities
   int_to_string (const unsigned int i,
                 const unsigned int digits)
   {
+                                    // if second argument is invalid, then do
+                                    // not pad the resulting string at all
+    if (digits == deal_II_numbers::invalid_unsigned_int)
+      return int_to_string (i, needed_digits(i));
+    
+    
     AssertThrow ( ! ((digits==1 && i>=10)   ||
                     (digits==2 && i>=100)  ||
                     (digits==3 && i>=1000) ||
index 2090901be21a53f3307811b4dbc2bc4d6c18cc17..020989711b038cd6fd5be647943c37169441533f 100644 (file)
@@ -343,6 +343,12 @@ inconvenience this causes.
 <h3>base</h3>
 
 <ol>
+  <li> <p> New: The second argument to <code>Utilities::int_to_string</code>
+       can now be omitted, leading to a string that isn't zero padded at all.
+       <br>
+       (WB 2006/08/02)
+       </p>
+
   <li> <p> Changed: When there is still a <code>SmartPointer</code> object
        pointing to another object at the time it is destroyed, this would cause
        the program to be aborted. However, there are cases where this is not
index cd6556527f0f8c9980be48a2b4aa33070881cbec..724682a11862e78d3ca76cef07162650bfc3a4bf 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$ 
 //
-//    Copyright (C) 2005 by the deal.II authors
+//    Copyright (C) 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -25,6 +25,7 @@
 void test () 
 {
   deallog << Utilities::int_to_string (42,4) << std::endl;
+  deallog << Utilities::int_to_string (42) << std::endl;
   deallog << Utilities::needed_digits (424) << std::endl;
   deallog << Utilities::string_to_int (" 413 ") << std::endl;
 
index 5e6f7201097f895848b9c69ec3495d4f428499fc..ec35899b286d2dd55d3be2ab254082e25cd35c9b 100644 (file)
@@ -1,5 +1,6 @@
 
 DEAL::0042
+DEAL::42
 DEAL::3
 DEAL::413
 DEAL::1

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.