From owner-freebsd-standards@FreeBSD.ORG Mon Jul 18 11:02:30 2005 Return-Path: X-Original-To: freebsd-standards@freebsd.org Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 70CBE16A425 for ; Mon, 18 Jul 2005 11:02:30 +0000 (GMT) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2471F43D4C for ; Mon, 18 Jul 2005 11:02:30 +0000 (GMT) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (peter@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6IB2Uiu098346 for ; Mon, 18 Jul 2005 11:02:30 GMT (envelope-from owner-bugmaster@freebsd.org) Received: (from peter@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6IB2SQQ098340 for freebsd-standards@freebsd.org; Mon, 18 Jul 2005 11:02:28 GMT (envelope-from owner-bugmaster@freebsd.org) Date: Mon, 18 Jul 2005 11:02:28 GMT Message-Id: <200507181102.j6IB2SQQ098340@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: peter set sender to owner-bugmaster@freebsd.org using -f From: FreeBSD bugmaster To: freebsd-standards@FreeBSD.org Cc: Subject: Current problem reports assigned to you X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2005 11:02:30 -0000 Current FreeBSD problem reports Critical problems Serious problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2001/03/05] bin/25542 standards /bin/sh: null char in quoted string p [2002/02/25] standards/35307standards standard include files are not standard c o [2002/12/13] kern/46239 standards posix semaphore implementation errors o [2003/04/21] standards/51209standards [PATCH] add a64l()/l64a/l64a_r functions p [2003/06/05] standards/52972standards /bin/sh arithmetic not POSIX compliant o [2003/07/12] standards/54410standards one-true-awk not POSIX compliant (no exte o [2004/11/03] standards/73500standards 'set +o' in /bin/sh does not include unse o [2005/03/03] standards/78357standards getaddrinfo() doesn't appear to support A o [2005/06/25] standards/82654standards C99 long double math functions are missin 9 problems total. Non-critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2000/09/24] bin/21519 standards sys/dir.h should be deprecated some more o [2001/01/16] bin/24390 standards Replacing old dir-symlinks when using /bi s [2001/01/24] standards/24590standards timezone function not compatible witn Sin s [2001/06/18] kern/28260 standards UIO_MAXIOV needs to be made public p [2001/11/20] standards/32126standards getopt(3) not Unix-98 conformant s [2002/03/19] standards/36076standards Implementation of POSIX fuser command o [2002/06/14] standards/39256standards [v]snprintf aren't POSIX-conformant for s o [2002/07/09] kern/40378 standards stdlib.h gives needless warnings with -an p [2002/08/12] standards/41576standards POSIX compliance of ln(1) o [2002/10/23] standards/44425standards getcwd() succeeds even if current dir has o [2002/12/09] standards/46119standards Priority problems for SCHED_OTHER using p o [2003/07/24] standards/54809standards pcvt deficits o [2003/07/25] standards/54833standards more pcvt deficits o [2003/07/25] standards/54839standards pcvt deficits o [2003/07/31] standards/55112standards glob.h, glob_t's gl_pathc should be "size o [2003/09/05] standards/56476standards cd9660 unicode support simple hack o [2003/10/29] standards/58676standards grantpt(3) alters storage used by ptsname s [2004/02/14] standards/62858standards malloc(0) not C99 compliant p [2004/02/21] standards/63173standards Patch to add getopt_long_only(3) to libc o [2004/03/29] kern/64875 standards [patch] add a system call: fdatasync() o [2004/05/07] standards/66357standards make POSIX conformance problem ('sh -e' & o [2004/05/11] standards/66531standards _gettemp uses a far smaller set of filena o [2004/08/22] standards/70813standards [PATCH] ls not Posix compliant o [2004/08/26] docs/70985 standards [patch] sh(1): incomplete documentation o o [2004/09/22] standards/72006standards floating point formating in non-C locales o [2005/03/20] standards/79055standards Add an IFS regression test for shells o [2005/03/20] standards/79056standards regex(3) regression tests o [2005/03/21] standards/79067standards /bin/sh should be more intelligent about o [2005/05/20] standards/81287standards [PATCH]: fingerd(8) might send a line not 29 problems total. From owner-freebsd-standards@FreeBSD.ORG Mon Jul 18 12:32:32 2005 Return-Path: X-Original-To: freebsd-standards@hub.freebsd.org Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 36D0A16A41F; Mon, 18 Jul 2005 12:32:32 +0000 (GMT) (envelope-from schweikh@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id EA62C43D48; Mon, 18 Jul 2005 12:32:31 +0000 (GMT) (envelope-from schweikh@FreeBSD.org) Received: from freefall.freebsd.org (schweikh@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6ICWVag014590; Mon, 18 Jul 2005 12:32:31 GMT (envelope-from schweikh@freefall.freebsd.org) Received: (from schweikh@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6ICWVIF014586; Mon, 18 Jul 2005 12:32:31 GMT (envelope-from schweikh) Date: Mon, 18 Jul 2005 12:32:31 GMT From: Jens Schweikhardt Message-Id: <200507181232.j6ICWVIF014586@freefall.freebsd.org> To: schweikh@schweikhardt.net, schweikh@FreeBSD.org, freebsd-standards@FreeBSD.org Cc: Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2005 12:32:32 -0000 Synopsis: /bin/sh arithmetic not POSIX compliant State-Changed-From-To: patched->closed State-Changed-By: schweikh State-Changed-When: Mon Jul 18 12:31:36 GMT 2005 State-Changed-Why: I have no intention to backport this to RELENG_4. http://www.freebsd.org/cgi/query-pr.cgi?pr=52972 From owner-freebsd-standards@FreeBSD.ORG Thu Jul 21 12:01:25 2005 Return-Path: X-Original-To: freebsd-standards@hub.freebsd.org Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D35A116A41F for ; Thu, 21 Jul 2005 12:01:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 572E143D53 for ; Thu, 21 Jul 2005 12:00:35 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6LC0YZM005119 for ; Thu, 21 Jul 2005 12:00:34 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6LC0Ygk005118; Thu, 21 Jul 2005 12:00:34 GMT (envelope-from gnats) Resent-Date: Thu, 21 Jul 2005 12:00:34 GMT Resent-Message-Id: <200507211200.j6LC0Ygk005118@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-standards@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Roman Bogorodskiy Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7A06216A41F for ; Thu, 21 Jul 2005 11:54:40 +0000 (GMT) (envelope-from bogorodskiy@gmail.com) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.192]) by mx1.FreeBSD.org (Postfix) with ESMTP id 88B1043D68 for ; Thu, 21 Jul 2005 11:54:20 +0000 (GMT) (envelope-from bogorodskiy@gmail.com) Received: by rproxy.gmail.com with SMTP id r35so177625rna for ; Thu, 21 Jul 2005 04:54:19 -0700 (PDT) Received: by 10.38.151.80 with SMTP id y80mr1391097rnd; Thu, 21 Jul 2005 04:54:02 -0700 (PDT) Received: from localhost ([195.161.252.171]) by mx.gmail.com with ESMTP id g2sm205032rne.2005.07.21.04.53.33; Thu, 21 Jul 2005 04:54:02 -0700 (PDT) Message-Id: <42df8cda.49123896.2132.368c@mx.gmail.com> Date: Thu, 21 Jul 2005 04:54:02 -0700 (PDT) From: Roman Bogorodskiy To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: standards/83845: [ patch ] add log2() and log2f() support for libm X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Roman Bogorodskiy List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2005 12:01:26 -0000 >Number: 83845 >Category: standards >Synopsis: [ patch ] add log2() and log2f() support for libm >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Jul 21 12:00:34 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Roman Bogorodskiy >Release: FreeBSD 7.0-CURRENT i386 >Organization: >Environment: System: FreeBSD lame.novel.ru 7.0-CURRENT FreeBSD 7.0-CURRENT #17: Wed Jul 20 11:32:19 MSD 2005 root@lame.novel.ru:/usr/obj/usr/src/sys/NOVEL i386 >Description: Add e_log2.c and e_log2f.c files based on e_log.c and e_logf.c respectively which adds support of C99 funtions log2() and log2f(). The idea is simple: log(N) to base A is equal to logN/logA, that way, log2(x) = log(x)/log(2). So after some simplifications and deviding result by precalculated value of log(2) we can compute the value of the logarithm of argument x to base 2. Patch is attached. You can also pick it up here: http://people.freebsd.org/~novel/patches/freebsd/msun_log2_and_log2f.diff >How-To-Repeat: >Fix: --- msun_log2_and_log2f.diff begins here --- diff -ruN /usr/src.bak/lib/msun/Makefile lib/msun/Makefile --- /usr/src.bak/lib/msun/Makefile Sun Jul 17 17:47:52 2005 +++ lib/msun/Makefile Thu Jul 21 15:00:25 2005 @@ -33,7 +33,7 @@ e_expf.c e_fmod.c e_fmodf.c e_gamma.c e_gamma_r.c e_gammaf.c \ e_gammaf_r.c e_hypot.c e_hypotf.c e_j0.c e_j0f.c e_j1.c e_j1f.c \ e_jn.c e_jnf.c e_lgamma.c e_lgamma_r.c e_lgammaf.c e_lgammaf_r.c \ - e_log.c e_log10.c e_log10f.c e_logf.c e_pow.c e_powf.c e_rem_pio2.c \ + e_log.c e_log2.c e_log10.c e_log10f.c e_log2f.c e_logf.c e_pow.c e_powf.c e_rem_pio2.c \ e_rem_pio2f.c e_remainder.c e_remainderf.c e_scalb.c e_scalbf.c \ e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c fenv.c \ k_cos.c k_cosf.c k_rem_pio2.c k_rem_pio2f.c k_sin.c k_sinf.c \ @@ -114,7 +114,8 @@ MLINKS+=exp.3 expm1.3 exp.3 log.3 exp.3 log10.3 exp.3 log1p.3 exp.3 pow.3 \ exp.3 exp2.3 exp.3 exp2f.3 exp.3 expf.3 \ exp.3 expm1f.3 exp.3 logf.3 exp.3 powf.3 \ - exp.3 log10f.3 exp.3 log1pf.3 + exp.3 log10f.3 exp.3 log1pf.3 \ + exp.3 log2.3 exp.3 log2f.3 MLINKS+=fabs.3 fabsf.3 fabs.3 fabsl.3 MLINKS+=fdim.3 fdimf.3 fdim.3 fdiml.3 MLINKS+=feclearexcept.3 fegetexceptflag.3 feclearexcept.3 feraiseexcept.3 \ diff -ruN /usr/src.bak/lib/msun/man/exp.3 lib/msun/man/exp.3 --- /usr/src.bak/lib/msun/man/exp.3 Sun Jul 17 17:47:50 2005 +++ lib/msun/man/exp.3 Thu Jul 21 15:00:54 2005 @@ -45,6 +45,8 @@ .Nm expm1f , .Nm log , .Nm logf , +.Nm log2, +.Nm log2f, .Nm log10 , .Nm log10f , .Nm log1p , @@ -73,6 +75,10 @@ .Ft float .Fn logf "float x" .Ft double +.Fn log2 "double x" +.Ft float +.Fn log2f "float x" +.Ft double .Fn log10 "double x" .Ft float .Fn log10f "float x" @@ -114,6 +120,14 @@ .Fn logf functions compute the value of the natural logarithm of argument .Fa x . +.Pp +The +.Fn log2 +and the +.Fn log2f +functions compute the value of the logarithm of argument +.Fa x +to base 2. .Pp The .Fn log10 diff -ruN /usr/src.bak/lib/msun/src/e_log2.c lib/msun/src/e_log2.c --- /usr/src.bak/lib/msun/src/e_log2.c Thu Jan 1 03:00:00 1970 +++ lib/msun/src/e_log2.c Thu Jul 21 15:12:49 2005 @@ -0,0 +1,79 @@ + +/* @(#)e_log.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#ifndef lint +static char rcsid[] = "$FreeBSD$"; +#endif + +#include "math.h" +#include "math_private.h" + +static const double +ln2 = 0.6931471805599452862268, +two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ +Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ +Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ +Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ +Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ +Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ +Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ +Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ + +static const double zero = 0.0; + +double +__ieee754_log2(double x) +{ + double hfsq,f,s,z,R,w,t1,t2,dk; + int32_t k,hx,i,j; + u_int32_t lx; + + EXTRACT_WORDS(hx,lx,x); + + k=0; + if (hx < 0x00100000) { /* x < 2**-1022 */ + if (((hx&0x7fffffff)|lx)==0) + return -two54/zero; /* log(+-0)=-inf */ + if (hx<0) return (x-x)/zero; /* log(-#) = NaN */ + k -= 54; x *= two54; /* subnormal number, scale up x */ + GET_HIGH_WORD(hx,x); + } + if (hx >= 0x7ff00000) return x+x; + k += (hx>>20)-1023; + hx &= 0x000fffff; + i = (hx+0x95f64)&0x100000; + SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */ + k += (i>>20); + f = x-1.0; + dk = (double)k; + if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */ + if (f==zero) + return (dk); + R = f*f*(0.5-0.33333333333333333*f); + return (dk-(R-f)/ln2); + } + s = f/(2.0+f); + z = s*s; + i = hx-0x6147a; + w = z*z; + j = 0x6b851-hx; + t1= w*(Lg2+w*(Lg4+w*Lg6)); + t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); + i |= j; + R = t2+t1; + if(i>0) { + hfsq=0.5*f*f; + return (dk-(hfsq-s*(hfsq+R)-f)/ln2); + } else + return (dk-((s*(f-R))-f)/ln2); +} diff -ruN /usr/src.bak/lib/msun/src/e_log2f.c lib/msun/src/e_log2f.c --- /usr/src.bak/lib/msun/src/e_log2f.c Thu Jan 1 03:00:00 1970 +++ lib/msun/src/e_log2f.c Thu Jul 21 14:43:57 2005 @@ -0,0 +1,80 @@ +/* e_logf.c -- float version of e_log.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#ifndef lint +static char rcsid[] = "$FreeBSD$"; +#endif + +#include "math.h" +#include "math_private.h" + +static const float +ln2 = 0.6931471805599452862268, +two25 = 3.355443200e+07, /* 0x4c000000 */ +Lg1 = 6.6666668653e-01, /* 3F2AAAAB */ +Lg2 = 4.0000000596e-01, /* 3ECCCCCD */ +Lg3 = 2.8571429849e-01, /* 3E924925 */ +Lg4 = 2.2222198546e-01, /* 3E638E29 */ +Lg5 = 1.8183572590e-01, /* 3E3A3325 */ +Lg6 = 1.5313838422e-01, /* 3E1CD04F */ +Lg7 = 1.4798198640e-01; /* 3E178897 */ + +static const float zero = 0.0; + +float +__ieee754_log2f(float x) +{ + float hfsq,f,s,z,R,w,t1,t2,dk; + int32_t k,ix,i,j; + + GET_FLOAT_WORD(ix,x); + + k=0; + if (ix < 0x00800000) { /* x < 2**-126 */ + if ((ix&0x7fffffff)==0) + return -two25/zero; /* log(+-0)=-inf */ + if (ix<0) return (x-x)/zero; /* log(-#) = NaN */ + k -= 25; x *= two25; /* subnormal number, scale up x */ + GET_FLOAT_WORD(ix,x); + } + if (ix >= 0x7f800000) return x+x; + k += (ix>>23)-127; + ix &= 0x007fffff; + i = (ix+(0x95f64<<3))&0x800000; + SET_FLOAT_WORD(x,ix|(i^0x3f800000)); /* normalize x or x/2 */ + k += (i>>23); + dk = (float)k; + f = x-(float)1.0; + if((0x007fffff&(15+ix))<16) { /* |f| < 2**-20 */ + if (f==zero) + return (dk); + R = f*f*((float)0.5-(float)0.33333333333333333*f); + return (dk-(R-f)/ln2); + } + s = f/((float)2.0+f); + z = s*s; + i = ix-(0x6147a<<3); + w = z*z; + j = (0x6b851<<3)-ix; + t1= w*(Lg2+w*(Lg4+w*Lg6)); + t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); + i |= j; + R = t2+t1; + if(i>0) { + hfsq=(float)0.5*f*f; + return (dk-(hfsq-s*(hfsq+R)-f)/ln2); + } else + return (dk-((s*(f-R))-f)/ln2); +} diff -ruN /usr/src.bak/lib/msun/src/math.h lib/msun/src/math.h --- /usr/src.bak/lib/msun/src/math.h Sun Jul 17 17:47:52 2005 +++ lib/msun/src/math.h Thu Jul 21 14:25:21 2005 @@ -203,6 +203,7 @@ double frexp(double, int *); /* fundamentally !__pure2 */ double ldexp(double, int); double log(double); +double log2(double); double log10(double); double modf(double, double *); /* fundamentally !__pure2 */ @@ -314,6 +315,7 @@ float ldexpf(float, int); float log10f(float); float log1pf(float); +float log2f(float); float logf(float); float modff(float, float *); /* fundamentally !__pure2 */ diff -ruN /usr/src.bak/lib/msun/src/math_private.h lib/msun/src/math_private.h --- /usr/src.bak/lib/msun/src/math_private.h Sun Jul 17 17:47:52 2005 +++ lib/msun/src/math_private.h Thu Jul 21 14:45:31 2005 @@ -176,6 +176,7 @@ #define __ieee754_lgamma_r lgamma_r #define __ieee754_gamma_r gamma_r #define __ieee754_log10 log10 +#define __ieee754_log2 log2 #define __ieee754_sinh sinh #define __ieee754_hypot hypot #define __ieee754_j0 j0 @@ -202,6 +203,7 @@ #define __ieee754_lgammaf_r lgammaf_r #define __ieee754_gammaf_r gammaf_r #define __ieee754_log10f log10f +#define __ieee754_log2f log2f #define __ieee754_sinhf sinhf #define __ieee754_hypotf hypotf #define __ieee754_j0f j0f --- msun_log2_and_log2f.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-standards@FreeBSD.ORG Thu Jul 21 18:10:21 2005 Return-Path: X-Original-To: freebsd-standards@hub.freebsd.org Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2F6B716A436 for ; Thu, 21 Jul 2005 18:10:21 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7A50543D62 for ; Thu, 21 Jul 2005 18:10:18 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6LIAI0O061930 for ; Thu, 21 Jul 2005 18:10:18 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6LIAIdQ061929; Thu, 21 Jul 2005 18:10:18 GMT (envelope-from gnats) Date: Thu, 21 Jul 2005 18:10:18 GMT Message-Id: <200507211810.j6LIAIdQ061929@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: David Schultz Cc: Subject: Re: standards/83845: [ patch ] add log2() and log2f() support for libm X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: David Schultz List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2005 18:10:21 -0000 The following reply was made to PR standards/83845; it has been noted by GNATS. From: David Schultz To: Roman Bogorodskiy Cc: FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: standards/83845: [ patch ] add log2() and log2f() support for libm Date: Thu, 21 Jul 2005 14:07:08 -0400 On Thu, Jul 21, 2005, Roman Bogorodskiy wrote: > Add e_log2.c and e_log2f.c files based on e_log.c and e_logf.c > respectively which adds support of C99 funtions log2() and log2f(). > > The idea is simple: > > log(N) to base A is equal to logN/logA, that way, log2(x) = log(x)/log(2). > So after some simplifications and deviding result by precalculated value of > log(2) we can compute the value of the logarithm of argument x to base 2. Though this seems like a reasonable approach, it leads to significant rounding errors since it requires dividing an inexact result (ln(x) rounded to 52 bits) by another inexact quantity (ln(2) rounded to 52 bits). For instance, I suspect that if you computed log2(2), log2(4), log2(8), log2(16), ... using your implementation, the results would not always be exact. Technically speaking I don't think they are required to be exact, but common sense suggests that they ought to be. A more minor objection is that log2() can be computed more quickly than log(), but this impelementation does it less quickly. This isn't such a big deal, though; I'm more concerned about the problem that accuracy guarantees will be significantly weaker than for other routines in libm. --David From owner-freebsd-standards@FreeBSD.ORG Thu Jul 21 18:50:33 2005 Return-Path: X-Original-To: freebsd-standards@hub.freebsd.org Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 01C1A16A420 for ; Thu, 21 Jul 2005 18:50:33 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 775C243D53 for ; Thu, 21 Jul 2005 18:50:19 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6LIoJK6064860 for ; Thu, 21 Jul 2005 18:50:19 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6LIoJr1064859; Thu, 21 Jul 2005 18:50:19 GMT (envelope-from gnats) Date: Thu, 21 Jul 2005 18:50:19 GMT Message-Id: <200507211850.j6LIoJr1064859@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Roman Bogorodskiy Cc: Subject: Re: standards/83845: [ patch ] add log2() and log2f() support for libm X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Roman Bogorodskiy List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2005 18:50:33 -0000 The following reply was made to PR standards/83845; it has been noted by GNATS. From: Roman Bogorodskiy To: David Schultz Cc: FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: standards/83845: [ patch ] add log2() and log2f() support for libm Date: Thu, 21 Jul 2005 22:51:31 +0400 David wrote: > Though this seems like a reasonable approach, it leads to > significant rounding errors since it requires dividing an inexact > result (ln(x) rounded to 52 bits) by another inexact quantity > (ln(2) rounded to 52 bits). For instance, I suspect that if you > computed log2(2), log2(4), log2(8), log2(16), ... using your > implementation, the results would not always be exact. > Technically speaking I don't think they are required to be exact, > but common sense suggests that they ought to be. Is not it exact? $> ./a.out=20 log2(2) =3D 1.0000000000000000000000 log2(4) =3D 2.0000000000000000000000 log2(8) =3D 3.0000000000000000000000 log2(16) =3D 4.0000000000000000000000 $>=20 It's exact enough for me. > A more minor objection is that log2() can be computed more quickly > than log(), but this impelementation does it less quickly. This > isn't such a big deal, though; I'm more concerned about the > problem that accuracy guarantees will be significantly weaker than > for other routines in libm. Ok. You know, log2() confirms to C99 and some apps become to use it now. Su= re,=20 it's not problem for me to add hacks like #define log2(x) log(x)/log(2) whi= le=20 you're looking for the ideal solution. Roman Bogorodskiy From owner-freebsd-standards@FreeBSD.ORG Fri Jul 22 17:55:18 2005 Return-Path: X-Original-To: freebsd-standards@hub.freebsd.org Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CB7C216A447 for ; Fri, 22 Jul 2005 17:55:17 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3EF94446C6 for ; Fri, 22 Jul 2005 17:00:29 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6MH0TvT078681 for ; Fri, 22 Jul 2005 17:00:29 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6MH0Ts3078680; Fri, 22 Jul 2005 17:00:29 GMT (envelope-from gnats) Resent-Date: Fri, 22 Jul 2005 17:00:29 GMT Resent-Message-Id: <200507221700.j6MH0Ts3078680@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-standards@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Justin T. Gibbs" Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6B29616A41F for ; Fri, 22 Jul 2005 16:53:33 +0000 (GMT) (envelope-from gibbs@aslan.scsiguy.com) Received: from aslan.scsiguy.com (aslan.scsiguy.com [63.229.232.106]) by mx1.FreeBSD.org (Postfix) with ESMTP id C2AE943FDD for ; Fri, 22 Jul 2005 16:25:39 +0000 (GMT) (envelope-from gibbs@aslan.scsiguy.com) Received: from aslan.scsiguy.com (localhost [127.0.0.1]) by aslan.scsiguy.com (8.13.3/8.13.3) with ESMTP id j6MGPcWY064479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 22 Jul 2005 10:25:38 -0600 (MDT) (envelope-from gibbs@aslan.scsiguy.com) Received: (from gibbs@localhost) by aslan.scsiguy.com (8.13.3/8.13.3/Submit) id j6MGPchr064478; Fri, 22 Jul 2005 10:25:38 -0600 (MDT) (envelope-from gibbs) Message-Id: <200507221625.j6MGPchr064478@aslan.scsiguy.com> Date: Fri, 22 Jul 2005 10:25:38 -0600 (MDT) From: "Justin T. Gibbs" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: standards/83919: ls man page "sort by size" example out not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "Justin T. Gibbs" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2005 17:55:18 -0000 >Number: 83919 >Category: standards >Synopsis: ls man page "sort by size" example out not POSIX compliant >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: doc-bug >Submitter-Id: current-users >Arrival-Date: Fri Jul 22 17:00:28 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Justin T. Gibbs >Release: FreeBSD 5.4-STABLE i386 >Organization: >Environment: System: FreeBSD aslan.scsiguy.com 5.4-STABLE FreeBSD 5.4-STABLE #7: Sat May 21 21:03:20 MDT 2005 gibbs@aslan.scsiguy.com:/usr/src/sys/i386/compile/ASLAN i386 >Description: The ls man page contains the following example: ls -l | sort -n +4 The +POS [-POS] origin-zero syntax to specify sort keys is not allowed per POSIX 1003.1-2001. The sort man page doesn't even mention this syntax any longer. (Our sort does still honor the syntax.) A more correct example would be: ls -l | sort -n -k 5 >How-To-Repeat: man ls >Fix: Convert the above corrected example into mdoc, replacing the current example. >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-standards@FreeBSD.ORG Sat Jul 23 02:10:20 2005 Return-Path: X-Original-To: freebsd-standards@hub.freebsd.org Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4C63016A41F for ; Sat, 23 Jul 2005 02:10:20 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1E57E43D45 for ; Sat, 23 Jul 2005 02:10:20 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6N2AJAD062458 for ; Sat, 23 Jul 2005 02:10:19 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6N2AJ2S062457; Sat, 23 Jul 2005 02:10:19 GMT (envelope-from gnats) Date: Sat, 23 Jul 2005 02:10:19 GMT Message-Id: <200507230210.j6N2AJ2S062457@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: "Steven G. Kargl" Cc: Subject: Re: standards/83845: [ patch ] add log2() and log2f() support for libm X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "Steven G. Kargl" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jul 2005 02:10:20 -0000 The following reply was made to PR standards/83845; it has been noted by GNATS. From: "Steven G. Kargl" To: bug-followup@FreeBSD.org, bogorodskiy@gmail.com Cc: Subject: Re: standards/83845: [ patch ] add log2() and log2f() support for libm Date: Fri, 22 Jul 2005 19:02:15 -0700 See standards/82654. I have implementations for several C99 long double math functions, and in the process I implemented log2 and logf. I also wrote or edited the man pages. IMHO, for log2[fl], we want to use frexp[fl] to break x into x = f * 2**n where f is in the range [0.5,1). We then have log2(x) = n + log2(f). We can now either evaluate log2(f) as log(f)/log(2) or directly use a polynomial approximation. -- steve From owner-freebsd-standards@FreeBSD.ORG Sat Jul 23 04:50:20 2005 Return-Path: X-Original-To: freebsd-standards@hub.freebsd.org Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5BCFC16A41F for ; Sat, 23 Jul 2005 04:50:20 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 26A5343D48 for ; Sat, 23 Jul 2005 04:50:20 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6N4oKQ2087349 for ; Sat, 23 Jul 2005 04:50:20 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6N4oJnb087348; Sat, 23 Jul 2005 04:50:19 GMT (envelope-from gnats) Date: Sat, 23 Jul 2005 04:50:19 GMT Message-Id: <200507230450.j6N4oJnb087348@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Roman Bogorodskiy Cc: Subject: Re: standards/83845: [ patch ] add log2() and log2f() support for libm X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Roman Bogorodskiy List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jul 2005 04:50:20 -0000 The following reply was made to PR standards/83845; it has been noted by GNATS. From: Roman Bogorodskiy To: "Steven G. Kargl" Cc: bug-followup@FreeBSD.org Subject: Re: standards/83845: [ patch ] add log2() and log2f() support for libm Date: Sat, 23 Jul 2005 08:50:13 +0400 --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Steven wrote: > See standards/82654. >=20 > I have implementations for several C99 long double math functions, > and in the process I implemented log2 and logf. I also wrote or That's really great, since our libmath is a bit outdated and nobody seems to care about that. > edited the man pages. IMHO, for log2[fl], we want to use frexp[fl] > to break x into x =3D f * 2**n where f is in the range [0.5,1). We > then have log2(x) =3D n + log2(f). We can now either evaluate log2(f) > as log(f)/log(2) or directly use a polynomial approximation. That looks reasonable. Actually, I don't care which implementation will be used, your or mine or some another, I'd just like to have it implemented. But looking at the batch of open standarts PRs I think we have no chance to get it committed in the near future. :( Roman Bogorodskiy --qMm9M+Fa2AknHoGS Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (FreeBSD) iQCVAwUBQuHMhYB0WzgdqspGAQKjRgP8Dz5gl/1TVHAhQNGOHEMkOtmFSV3JZmpf 7yUlIQ3Q3Olh6WKVIdvgX1JdV9Fia/VJhea4ESJx85OrgSl8gQsmYZJhO2sSm2Kj 5OINHr68rVsMdY24F6ZiNOTOkeQZySfLX6m0sVsfrY/GIFEBqpQiqbnsTmSqZUx4 WTeishBNtqU= =+Ngs -----END PGP SIGNATURE----- --qMm9M+Fa2AknHoGS--