www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2026/06/06/08:20:34

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 656CKX2Z3785802
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 656CKX2Z3785802
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=QBXRi+ip
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A34C64C3185D
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1780748432;
bh=3wMvuNTV47avELNyIceZsEgyBvpKB75ISbtExHNmwBc=;
h=Subject:In-Reply-To:Date:Cc:References:To:List-Id:
List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
From:Reply-To:From;
b=QBXRi+ipy06iR7fmWZ3W8xEnv7oCpUNDxGKake1ZYFWv+9SgSdIs+3GqfnL7MfuTS
OhSyee5987vhOohuMVUefYlkR3T8zDwdV/JUMr0W1b4soFIt1huO8WI98HpsvoZEks
IsnCa76Epvz9KhqOCLlQgt9OYUhpFCb5tDM7kpro=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 437684BA23C8
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 437684BA23C8
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780748383; cv=none;
b=m/ZYVe/Cd6mjzeGJpcBIQH0Yq28p53s6HBqrsTiHoW3zaGAPR2jzLuzqfvdusyPAXgJrDInC24ouSIpa84rdCca4Euwqnld8toB8/0JAXcQyF8zDqMa5wGPkDiv4VqSPXjCEivqwGFS3r2b1n6AsmHLWuMdRKFLWF2AR39eJOgI=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1780748383; c=relaxed/simple;
bh=ibIHvKobG3h1NvQIVxcB11iaH1kJdddJmY//hm38924=;
h=DKIM-Signature:Mime-Version:Subject:From:Date:Message-Id:To;
b=eVzDi9mBBEtZ/2Dr4a+SxcKKHCbu9FjwO5iwTQuRjCin/8haWKRyVgfc36w9UAm5mUUX5sdDdYCt5R0uhCwP2vV4JlzVqK2hGPjw8RJ8DnhenPkwqyUMgj7IGNhTlorg/eE4/GEFs/jtUtqGh8Q8/9nI5UB95PCta/cyMMH9yLI=
ARC-Authentication-Results: i=1; sourceware.org;
dkim=pass (2048-bit key, secure)
header.d=unified-streaming.com header.i=@unified-streaming.com
header.a=rsa-sha256 header.s=google header.b=M4KcVZVo
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 437684BA23C8
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1780748382; x=1781353182;
h=to:references:message-id:content-transfer-encoding:cc:date
:in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state
:from:to:cc:subject:date:message-id:reply-to;
bh=uhvI/DCexIJt3j3pIC88HJgolXkwcGORTDFuLt2p9bk=;
b=oSWuNnuObWkP1G19xcQifsx1JC9xaO6E4NdCfASMsvZvVx8M3Nvg955TPN/JWKUdzX
F9BdWaF9lw8pNQgrZnNOosWHWthxyGjY2CPM9sugQLluh8XTNyrn/L/7Vu+rBpUdrLuJ
HIXmjI7g6gHnHXOErd7l4PKnWSjCYoM57qxAO7SEle8+7z43yRGjlpAj7/3SdwIl4fTe
NmI//cOSKkhpeO/6VUawYMgyBxjbvyv6nq9V2MR5+aeWnFm6D5zn/HVqroVsHcHewRj1
j9a+1qmNubMFNuSno1h3ECRsO/2DrWDnhXxrzaBPiUyLrh0KRHI4SwNIPmBGqDkC9QIq
X7Zw==
X-Gm-Message-State: AOJu0YyoCV1TdCXhNoossAZYosBkuGF9RQzYDvdWgbD2P1c/uvvxd4Ky
7YLPR9br2N0y4tkFZtyKXFmtL7QLPFb+R1rWKJuA6/r+PaDqqzUZ9RUEq6ZSWNrW3goo/vuqEbV
UcwGeU6A=
X-Gm-Gg: Acq92OFSclCnnDBNzfBJYD6lJtA0SsWd2QypmXIX0jHCeN6ZqITi2IYjVbO7jcKmE0B
gO5hF9sVhhz6GismuSenaXazcKNnKBWhWRcfJL1G9StlVcXiNIiIVfjU3vxEfiLGOVuVEKsPiOt
oimFMqaSNoV+4raIuyCmS0O6pMsbtu/zNnUFZHMWFGC2RfEYRvZ8vY6GbuzxPiqKFzvvZmDqmC3
CGtjoTXqtqZMjHJqq0BST2y1TEkESgGyXjg4GsoUnvwpoSAbaaeaRSZZinUYVmjz+YO0Dg0lHBS
Wq5rZmnPtInQMIPjOUcv5zQnSJZMgvrJbQZqLv39uEa17bOvC/orQ73CftkHrpBaD67KOsemM4e
LRrYL3YcKXZTFxjFWbQbeDgWrFuxFDnKVkT98K1i13+SWG/wadiqlECQ0Pkesw8hViL9rdzKRHv
4vArd8PSGwdFqXR+HNIOIsU0122NNecANNmqPkuRhNy40XoLcuYvR5mEg/PhKUDIzwyu8Ce17lW
BCqqo/0vYmqMpc=
X-Received: by 2002:a17:907:7b8c:b0:beb:c3a7:9cd with SMTP id
a640c23a62f3a-bf36fba1c96mr388027266b.8.1780748381866;
Sat, 06 Jun 2026 05:19:41 -0700 (PDT)
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81.1.8\))
Subject: Re: log2() is not called for C code, a bug into math.h ?
In-Reply-To: <CADt9577cpSu1Ke7xu6mMQgfyfdOg8qFg1YFWRXQ_4NbmJto2Ug@mail.gmail.com>
Date: Sat, 6 Jun 2026 14:19:41 +0200
Cc: The Cygwin Mailing List <cygwin AT cygwin DOT com>
Message-Id: <C907B908-9877-431C-B9AA-50F63ABA581C@unified-streaming.com>
References: <CADt9577cpSu1Ke7xu6mMQgfyfdOg8qFg1YFWRXQ_4NbmJto2Ug AT mail DOT gmail DOT com>
To: "Carlo B." <carlo DOT bramini AT gmail DOT com>
X-Mailer: Apple Mail (2.3826.700.81.1.8)
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Dimitry Andric via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Dimitry Andric <dimitry AT unified-streaming DOT com>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

On 6 Jun 2026, at 13:42, Carlo B. via Cygwin <cygwin AT cygwin DOT com> wrote:
> 
> Hello,
> look this tiny C source code:
> 
> ========
> 
> #include <stdio.h>
> #include <math.h>
> 
> int main()
> {
>    double value = 0x1p1023;
> 
>    printf("log2=%.14f\n", log2(value));
> #undef log2
>    printf("log2=%.14f\n", log2(value));
> 
>    return 0;
> }
> 
> ========
> 
> Compile it with a simple command:
> 
> $ gcc test_log2.c -o test_log2.exe
> 
> and run it.
> The result on the console is:
> 
> log2=1023.00000000000011
> log2=1023.00000000000000
> 
> If you look inside math.h from newlib, you will see this code:
> 
> extern double log2 (double);
> #if !defined(__cplusplus)
> #define log2(x) (log (x) / _M_LN2)
> #endif
> 
> As you can see, my simple test program just calculates log2() by using
> log() function and next, after undefining log2() macro, it uses the
> true log2() function.
> 
> Actually, that macro log2() "overloads" the log2() function.
> And as result, the calculation of "(log (x) / _M_LN2)" loses the
> precision on the last bits of the result.
> It is not clear to me if there is a particular reason for doing so,
> because this thing makes the Python's test suite to fail on the tests
> for the log2() function.
> What do you think?
> Because log2() function was perfectly able to pass the tests.

It's been defined like that since the "import newlib-2000-02-17 snapshot", so for 26 years:

https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/include/math.h;h=d3f2e99ae4d33596b608225f0349a6d581d265ca;hb=8a0efa53e44919bcf5ccb1d3353618a82afdf8bc#l103

My guess is that at the time, there wasn't yet a separate log2() implementation, so this was an easy way to cover that case.

-Dimitry


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019