www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2026/06/06/07:43:41

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 656BhfVI3773595
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 656BhfVI3773595
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=iiooT/PD
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B31E4C31847
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1780746220;
bh=pH7alpay2jwGbaRFp4gRbHwOuu7OAVeIBhc0Kp/ayKA=;
h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=iiooT/PDSVhF/bq3nFtvV0hRaJxUZxoEqzvlvowsIZDJBxCsk25zVpPsm569Z30u2
ZBhjQ5f6HN9j1G0HOT3QOv7ZwJlgon4uM4BZB9ZKZjjSmbH7BsBT9g/fBjmvMh3+3o
Ru6wvWwuZFckJfEpsO7zy1dJIUR0FshnEVDVJpXg=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3A354BA2E21
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C3A354BA2E21
ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1780746172; cv=pass;
b=oeRSf2MepJwa8Tu4+5wA+KTmOPMRHtbH/wEp4Ml8rOYlis+d9xzDUvinvsfy4BfhVCa4Ykk3VeJPdyWGOHlJfWNlVQxZfNuvgXtctGnyap0VyiRpk4D8FTfWk6uafUbihVHDXDvCZHWjeHdQ4jikaq748IdC5hUEg1XTTpgRJmM=
ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key;
t=1780746172; c=relaxed/simple;
bh=ZtPtRDomG50pKYjJ8kJ5+KomRX7pdACkBWipi5bAA6k=;
h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;
b=VsCPJBGCbce33XsoeS5BmQiv5+A97UttAwE8dVn9LCykRrV57vr3j1Nh99hSRFGIbpqAqe7Fx2SO6f1WSZW8CU3dTcSdf5dHRsIJaIb/JQQUdk2A+Un52TQHF1gbgNlCY9WjwzN4N5u6Qal9+Vy7fzFX1bwZ8XIkqGuEQbcFcX0=
ARC-Authentication-Results: i=2; sourceware.org;
dkim=pass (2048-bit key, unprotected)
header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104
header.b=q1XfO4ky
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3A354BA2E21
ARC-Seal: i=1; a=rsa-sha256; t=1780746171; cv=none;
d=google.com; s=arc-20240605;
b=Y+/Ox6ppjDH1O5S9UBHX95PRYrmTGqOIF+BxPxYLeBbaTjOC54wQ1v79Yj+nIU54bB
qmDvBRmMmexZ1SlfXMLdotmiY9P1kXMgKx5si7D47d0jlbP9kBsXS2s8leEJ17Fpvhgo
jAhcGUSwuZuwlr/cCVe7gS5H2DuHqZ8hStiKkuFp2SPT9d8jJ2CNstxu3TAYd0WbhXLs
mND5GJmK/121jRK2tmDjPssXOa9jCSP2dqEl3UhtUWz+3HgfjD7MZ+Ce0kShQESgtaBd
0FxfWxkK/PX5jNCJxCnp7Zd6Mxs6FZ8DaZe89H0B3ugMnOd/+TkkZo8N6B2Ub4QY75Bd
y4CQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20240605;
h=to:subject:message-id:date:from:mime-version:dkim-signature;
bh=whfuLW1jm/2H5kEnfX+17d2sbo7j1CAY3Xwhqfd0u/M=;
fh=YZH5uM5/yfouasGmhd4aBgFJjkmPDWmx6Ke4uaPtCZY=;
b=QuTa3ILORPhn8LCsts1bUDyzuzdj4I3Y+YVYFizjEA+0V9cv7fnZfLr9SQvvPbPMCe
d2+L3mgKOTRXDeRf/AzIAhkb0oBNBjX++e8NKRNGXm62JdNml3Ue4cnaIaKfl06QnfAT
rovvpv49cOMyMLIXdOWbtwfL15uAs2ly41VVouE1fxUh+SAHZLp4u4pMZzkzVFAiHCFO
WryeDLR28E0AXNzGaEQ8NuJCS8IWp9P8uVeZTmxo3ZG5J/F0+TgWGpiU9iKhmkFD2NBR
b2mDfKLBqdmNOv/jWH2hdnX6rVZb8NqoS7rP+cyUnsFZQcDJVPk9q03JG34lmYOSwZji
VL1A==; darn=cygwin.com
ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1780746171; x=1781350971;
h=to:subject:message-id:date:from:mime-version:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=whfuLW1jm/2H5kEnfX+17d2sbo7j1CAY3Xwhqfd0u/M=;
b=FNCvHrDH2WN5uGSto1Cz4FTJEOT9o1sxoSDCrix06u6KsIPzSLJWteFa/X0acRwPZd
AwKuJpcvzL/e1ewifAwd89k9nxGYyWZGdU+bXDSNMmYDa9zwa3HZl2zlYFYz+qQrFR6E
xRAh5nbDTHE47uPluOnVC24YkqkADW73NchLCCxGssWoSixOKksWReRTsRJA5xwu09/q
l1N1dLargCQGBdVuxGVyC21wXaUD8Xs1OboXdZN8NIUWGPqyWOZdUOEnC7qR3ke1hscp
F/ocD5MMG77k78Mkks82WiLAxUX2K3dZCIdHoIovSQ5LkZ9BEaHn1OoZtgUFGJsLixy+
7xIg==
X-Gm-Message-State: AOJu0Yw8rAEQQeNug7c28ctrDqNvcQ4JkM1pTRRGUI1mR50bYttF8Kw6
VUcI90CEOhelBgGAVrENMxZXcGBmsgNvbf3IsTydiHr4S9+N4CKV3koZnBY056006f9nPffbj7D
vV7sxGGshCapMW1PSIRylm/gRF9uPGPFkTE5k
X-Gm-Gg: Acq92OFBO/z+TAh1VJ9Gn5oNH2sehQdOSEBud2yjbcj/MShfyNG2xjwXJ3FcmvzQsla
/5/HvESQs+xPC2k4Dj5h+jVI3FVh/A99Nzr/IIUPEpAnNOJS4qeduEJpWQZeSSSru/KnUd/osSc
QrsHWNGUHhZs99tWbuQHu4J/HNHC8gI/j/d+W9851j5Ui6WaDE3XOhufEX9dpIKDw22njGhJysZ
zY6G5LOLU6MLCo1J500AVG0OI//MAl+6YIBqokRY1xto3S8fgYgYIMdyyQiz/tYtd3wQAjV09Z1
W5w3Osa+amUxRmt/ypKt7afD0ydi1m4dC3zkIFhv7cpp30N8P7QGju6gCm2hpP98KZB9vXhFeJt
JUQ==
X-Received: by 2002:a5d:4d48:0:b0:45e:ea3a:47e8 with SMTP id
ffacd0b85a97d-4603050350cmr8795726f8f.24.1780746170567; Sat, 06 Jun 2026
04:42:50 -0700 (PDT)
MIME-Version: 1.0
Date: Sat, 6 Jun 2026 13:42:39 +0200
X-Gm-Features: AVVi8CfDfDiqD_3myA2vr7VlQGpg8aGk9Uv8DC3GGRZEnOBsl4dZSAKyMXn0U64
Message-ID: <CADt9577cpSu1Ke7xu6mMQgfyfdOg8qFg1YFWRXQ_4NbmJto2Ug@mail.gmail.com>
Subject: log2() is not called for C code, a bug into math.h ?
To: The Cygwin Mailing List <cygwin AT cygwin DOT com>
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-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: "Carlo B. via Cygwin" <cygwin AT cygwin DOT com>
Reply-To: "Carlo B." <carlo DOT bramini AT gmail DOT com>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

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.

Sincerely,

Carlo Bramini.

-- 
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