Fix out-of-range integer literals for threefry
authorErik Lindahl <erik@kth.se>
Sat, 6 Jun 2015 11:06:42 +0000 (13:06 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sun, 7 Jun 2015 04:49:42 +0000 (06:49 +0200)
The 64-bit literals need to have LL suffixes, or
xlc will warn about out-of-range literals and generate
code that fails the unit test. There was also a
single 64-bit literal in the implementation. Other
compilers appear to have handled this correctly,
so it is unlikely to have caused any user bug.

Refs #1725.

Change-Id: I575b6c12ace14973d4fae1edc81836686a2ff9d5

src/gromacs/random/random.cpp
src/gromacs/random/tests/random.cpp

index 8c442895f69cb65ad709b68b504ef2f16b9af8b2..9dcda9a40d390b287f91b8e4b33ca6bd0021892a 100644 (file)
@@ -397,7 +397,7 @@ gmx_rng_cycle_2uniform(gmx_uint64_t ctr1, gmx_uint64_t ctr2,
                        gmx_uint64_t key1, gmx_uint64_t key2,
                        double* rnd)
 {
-    const gmx_int64_t  mask_53bits     = 0x1FFFFFFFFFFFFF;
+    const gmx_int64_t  mask_53bits     = 0x1FFFFFFFFFFFFFULL;
     const double       two_power_min53 = 1.0/9007199254740992.0;
 
     threefry2x64_ctr_t ctr  = {{ctr1, ctr2}};
index e52a67d7a4185aaa59e721140bc0e1879a5d2e8b..371f08e5281e52966694df4a72457d61412b8349 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -78,9 +78,9 @@ const threefry2x64_ctr_t tf_zero = {{0, 0}};
 const threefry2x64_ctr_t tf_max  = {{std::numeric_limits<gmx_uint64_t>::max(),
                                      std::numeric_limits<gmx_uint64_t>::max()}};
 /** input value: Pi */
-const threefry2x64_ctr_t tf_pi1  = {{0x243f6a8885a308d3, 0x13198a2e03707344}};
+const threefry2x64_ctr_t tf_pi1  = {{0x243f6a8885a308d3ULL, 0x13198a2e03707344ULL}};
 /** input value: More Pi */
-const threefry2x64_ctr_t tf_pi2  = {{0xa4093822299f31d0, 0x082efa98ec4e6c89}};
+const threefry2x64_ctr_t tf_pi2  = {{0xa4093822299f31d0ULL, 0x082efa98ec4e6c89ULL}};
 
 INSTANTIATE_TEST_CASE_P(0_ff_pi, Threefry,
                             ::testing::Values(std::make_pair(tf_zero, tf_zero),