Skip to content

Commit 3dd0fce

Browse files
committed
libm: Improve powf accuracy
One of the constants, 'cp', was not correctly converted to extended precision (using two floats) leading to reduced precision in the computation of log2(x). The new values use a larger value for cp_h which is closer to the actual value. That leaves a smaller magnitude for cp_l resulting in increased precision for the result. These values were computed according to the Veltkamp/Dekker method. 2/(3*ln2): 0x1.ec709dc3a03fd748p-1 Old cp_h: 0x1.ec7p-1 New cp_h: 0x1.ec8p-1 The desired value is much closer to the higher value than the lower. Signed-off-by: Keith Packard <[email protected]>
1 parent 3ba2277 commit 3dd0fce

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

newlib/libm/math/sf_pow.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ lg2_h = 6.93145752e-01, /* 0x3f317200 */
4747
lg2_l = 1.42860654e-06, /* 0x35bfbe8c */
4848
ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */
4949
cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */
50-
cp_h = 9.6179199219e-01, /* 0x3f763800 =head of cp */
51-
cp_l = 4.7017383622e-06, /* 0x369dc3a0 =tail of cp_h */
50+
cp_h = 9.61914062e-01, /* 0x3f764000 =head of cp */
51+
cp_l = -1.17368574e-04, /* 0xb8f623c6 =tail of cp */
5252
ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */
5353
ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/
5454
ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/

0 commit comments

Comments
 (0)