Bug 229501 - [libm] Reduce diff between src/e_j0.c and src/e_j0f.c
Summary: [libm] Reduce diff between src/e_j0.c and src/e_j0f.c
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2018-07-03 19:04 UTC by sgk
Modified: 2019-01-14 15:49 UTC (History)
1 user (show)

See Also:


Attachments
Use literal constants (2.58 KB, patch)
2018-07-03 19:04 UTC, sgk
no flags Details | Diff
Use literal constants (3.07 KB, patch)
2019-01-08 15:39 UTC, Pedro F. Giffuni
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sgk 2018-07-03 19:04:27 UTC
Created attachment 194865 [details]
Use literal constants

The attached diff reduces the diff between src/e_j0.c and src/e_j0f.c.
Specifically, where possible it uses literal integer constants to
remove the need for casting a double literal constant to a float, and
it introduces 'static const <type> qrtr = 0.25' and 'static const <type>
eighth = 0.125' to eliminate the need for casting doubles to floats.
Exhaustive testing of j0f(x) in the domain [0,1e+30) shows no differences.

While here convert a sentence fragment in a comment to a sentence.
Comment 1 Pedro F. Giffuni freebsd_committer 2019-01-08 15:23:42 UTC
Looking at the patch:
--- src/e_j0f.c (revision 342861)
+++ src/e_j0f.c (working copy)
@@ -42,7 +42,7 @@
 S03  =  5.1354652442e-07, /* 0x3509daa6 */
 S04  =  1.1661400734e-09; /* 0x30a045e8 */
 
-static const float zero = 0.0;
+static const float zero = 0, qrtr = 0.25;
 
 float
 __ieee754_j0f(float x)
...

It is probably old school but I would  prefer we still use 0.0 for float.
Comment 2 Pedro F. Giffuni freebsd_committer 2019-01-08 15:39:45 UTC
Created attachment 200917 [details]
Use literal constants

Small variation of the patch, using 0.0 and 1.0 where pertinent.
Comment 3 Pedro F. Giffuni freebsd_committer 2019-01-14 15:08:44 UTC
Comment on attachment 200917 [details]
Use literal constants

According to bde@:

It's silly to use 0.0 for float in some contexts when the main point of
the patch is to use integer constants that will be converted to float
instead of explicit float constants.  0.0 isn't even a float constant,
but is converted to one before assignment to a float variable.

Also, static initialization to any type of 0 is redundant.
Comment 4 commit-hook freebsd_committer 2019-01-14 15:49:44 UTC
A commit references this bug:

Author: pfg
Date: Mon Jan 14 15:48:35 UTC 2019
New revision: 343023
URL: https://svnweb.freebsd.org/changeset/base/343023

Log:
  msun: reduce diff between src/e_j0.c and src/e_j0f.c

  PR:	229501
  MFC after:	1 week

Changes:
  head/lib/msun/src/e_j0.c
  head/lib/msun/src/e_j0f.c