limits (__glibcxx_digits10, [...]): Use 643L instead of 643 to avoid overflows on...
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 3 Nov 2010 17:33:54 +0000 (17:33 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 3 Nov 2010 17:33:54 +0000 (17:33 +0000)
2010-11-03  Paolo Carlini  <paolo.carlini@oracle.com>

* include/std/limits (__glibcxx_digits10, __glibcxx_max_digits10):
Use 643L instead of 643 to avoid overflows on 16-bit machines.
* include/ext/numeric_traits.h (__glibcxx_max_digits10): Likewise.

From-SVN: r166261

libstdc++-v3/ChangeLog
libstdc++-v3/include/ext/numeric_traits.h
libstdc++-v3/include/std/limits

index 0b7d3c2866002d7ee677a0989d4ad282f48e09ee..cc03f496f572c2bb0c1347ca88e08ab849f2b3a3 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-03  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * include/std/limits (__glibcxx_digits10, __glibcxx_max_digits10):
+       Use 643L instead of 643 to avoid overflows on 16-bit machines.
+       * include/ext/numeric_traits.h (__glibcxx_max_digits10): Likewise.
+
 2010-11-02  Benjamin Kosnik  <bkoz@redhat.com>
 
        * include/std/chrono: Use typedefs.
index 57fcf9c1fb8a7cd824027950fe2a52b8ccee685f..ab66a49358092ee0dcabb73be6a0690afa686a6e 100644 (file)
@@ -1,6 +1,6 @@
 // -*- C++ -*-
 
-// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -85,7 +85,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 
 #define __glibcxx_max_digits10(_Tp) \
   (2 + __glibcxx_floating(_Tp, __FLT_MANT_DIG__, __DBL_MANT_DIG__, \
-                         __LDBL_MANT_DIG__) * 3010 / 10000)
+                         __LDBL_MANT_DIG__) * 643L / 2136)
 
 #define __glibcxx_digits10(_Tp) \
   __glibcxx_floating(_Tp, __FLT_DIG__, __DBL_DIG__, __LDBL_DIG__)
index ce557d6a76c700d96ca08d7804baa0b65db98603..4594c93eb32029a94704cc80f97e92c828710001 100644 (file)
 
 // The fraction 643/2136 approximates log10(2) to 7 significant digits.
 #define __glibcxx_digits10(T) \
-  (__glibcxx_digits (T) * 643 / 2136)
+  (__glibcxx_digits (T) * 643L / 2136)
 
 #define __glibcxx_max_digits10(T) \
-  (2 + (T) * 643 / 2136)
+  (2 + (T) * 643L / 2136)
 
 _GLIBCXX_BEGIN_NAMESPACE(std)