[4/8] Add LIT() around literals in check_ulp in libm-tests.inc

Message ID be245395cdf20cd5c966d04902a46740bf3e681f.1463599718.git.murphyp@linux.vnet.ibm.com
State Superseded
Headers

Commit Message

Paul E. Murphy May 18, 2016, 8:55 p.m. UTC
  * math/libm-test.inc (check_ulp): Wrap floating point
	literals with LIT() instead of leaving them bare or
	appending the long double suffix.
---
 math/libm-test.inc | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
  

Comments

Joseph Myers May 18, 2016, 9:19 p.m. UTC | #1
On Wed, 18 May 2016, Paul E. Murphy wrote:

> -   ulps = ulp (0x0.0p0);
> +   ulps = ulp (LIT (0x0.0p0));

But ulp is a function and implicitly converts its argument.  You don't 
need the suffixes.  Just passing an integer 0 or 1 in these cases and 
relying on implicit conversions seems best, to make the code less 
macro-heavy.
  

Patch

diff --git a/math/libm-test.inc b/math/libm-test.inc
index f447cf9..d5dc5fc 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -11841,14 +11841,14 @@  check_ulp (void)
    FLOAT ulps, ulpx, value;
    int i;
    /* Check ulp of zero is a subnormal value...  */
-   ulps = ulp (0x0.0p0);
+   ulps = ulp (LIT (0x0.0p0));
    if (fpclassify (ulps) != FP_SUBNORMAL)
      {
        fprintf (stderr, "ulp (0x0.0p0) is not FP_SUBNORMAL!\n");
        exit (EXIT_FAILURE);
      }
    /* Check that the ulp of one is a normal value... */
-   ulps = ulp (1.0L);
+   ulps = ulp (LIT (1.0));
    if (fpclassify (ulps) != FP_NORMAL)
      {
        fprintf (stderr, "ulp (1.0L) is not FP_NORMAL\n");
@@ -11859,8 +11859,8 @@  check_ulp (void)
       We allow +/- 1 ulp around the represented value.  */
    value = FUNC(nextafter) (0, 1);
    ulps = ULPDIFF (value, 0);
-   ulpx = ulp (1.0L);
-   if (ulps < (1.0L - ulpx) || ulps > (1.0L + ulpx))
+   ulpx = ulp (LIT (1.0));
+   if (ulps < (LIT (1.0) - ulpx) || ulps > (LIT (1.0) + ulpx))
      {
        fprintf (stderr, "Value outside of 1 +/- 1ulp.\n");
        exit (EXIT_FAILURE);
@@ -11870,8 +11870,8 @@  check_ulp (void)
       We allow +/- 1 ulp around the represented value.  */
    value = FUNC(nextafter) (10, 20);
    ulps = ULPDIFF (value, 10);
-   ulpx = ulp (1.0L);
-   if (ulps < (1.0L - ulpx) || ulps > (1.0L + ulpx))
+   ulpx = ulp (LIT (1.0));
+   if (ulps < (LIT (1.0) - ulpx) || ulps > (LIT (1.0) + ulpx))
      {
        fprintf (stderr, "Value outside of 1 +/- 1ulp.\n");
        exit (EXIT_FAILURE);
@@ -11879,8 +11879,8 @@  check_ulp (void)
    /* This gives one more ulp.  */
    value = FUNC(nextafter) (value, 20);
    ulps = ULPDIFF (value, 10);
-   ulpx = ulp (2.0L);
-   if (ulps < (2.0L - ulpx) || ulps > (2.0L + ulpx))
+   ulpx = ulp (LIT (2.0));
+   if (ulps < (LIT (2.0) - ulpx) || ulps > (LIT (2.0) + ulpx))
      {
        fprintf (stderr, "Value outside of 2 +/- 1ulp.\n");
        exit (EXIT_FAILURE);
@@ -11889,8 +11889,8 @@  check_ulp (void)
    for (i = 2; i < 100; i++)
      value = FUNC(nextafter) (value, 20);
    ulps = ULPDIFF (value, 10);
-   ulpx = ulp (100.0L);
-   if (ulps < (100.0L - ulpx) || ulps > (100.0L + ulpx))
+   ulpx = ulp (LIT (100.0));
+   if (ulps < (LIT (100.0) - ulpx) || ulps > (LIT (100.0) + ulpx))
      {
        fprintf (stderr, "Value outside of 100 +/- 1ulp.\n");
        exit (EXIT_FAILURE);