www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2026/01/18/15:01:33

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 60IK1XY33734709
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 60IK1XY33734709
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=tI2z+OR2
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E44B4B9DB5E
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1768766491;
bh=A2ezdr8eZpmnESsNBa9sYIPrdPeVV+U/nvQcPi8Gme0=;
h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=tI2z+OR2t6xn8D9NXUDrdUL0LrG5CRPBi3OY9YbbwG1w/3Y7ltnOl42Ucvs6iOyRn
dtpCCA2up3xfwK+ZRWG2fmQKStocXI5GT3oFKLRvQki4vfOj07TxwamDtGxKM1ojSp
v4zFn3Yc3AfZP23k6pr2F38FVGxuZpoEc/gLfxdc=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F8EB4BA2E1D
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4F8EB4BA2E1D
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1768766443; cv=none;
b=RAWLST9DJv9LzCcxHCPFT3J3RUgaQvWtuDFTAMvik4U7sHH9JwZSBUX4SxticnMI6ynbyx4xuF4YWAYUAvXD9rJceYdyiXMfMBWWq6NTmKZk3D7+TYtDeSvwjM+8LFlRH4iG6kdsySEislg9SYdXYTZ7o8M+mAhlNKY4kVVOwns=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1768766443; c=relaxed/simple;
bh=7xQeZo2WXfb5rK3R7Np3kNDAvtH4jYYjU5nE7cGbdgk=;
h=DKIM-Signature:Date:From:To:Message-ID:Subject:MIME-Version;
b=OWHnk/vai4hT5LPJKH6NjtNrx15DjV5KARr44Tkv0KYBs8SXuozOBPHv6u79shM9cg+YnHKj/VFoQmTMfXjWaSuEr8OugreewVGGuk308PgH+vpbr7jNRWI+v23zCA0EzGi8XuCGwJvtxVIMnQwFTbDSQtIKwnR0VimFxijMMc0=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F8EB4BA2E1D
Date: Sun, 18 Jan 2026 12:00:40 -0800 (PST)
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Message-ID: <226987210.591128.1768766440723@connect.xfinity.com>
Subject: Log2 seems inefficient
MIME-Version: 1.0
X-Priority: 3
Importance: Normal
X-Mailer: Open-Xchange Mailer v7.10.6-Rev83
X-Originating-IP: ::ffff:50.47.202.14
X-Originating-Port: 24514
X-Originating-Client: open-xchange-appsuite
X-CMAE-Envelope: MS4xfFYlrJsTIOXIL0woea6ttAz4NlaEqvgfbjzFzwIuqyE4yM9PNqbWUAf1HTmJ8QUDL3zKAEXqJNZqJAEFfb9ZRTx3qhji2biTbw7gfmhciRLgyTqDOysG
2Dg4zDlH2TyfrFf326u8o1SNYY4px3ReL/es4s2ztVjDBc8Vn4fYJo9RepHvvyd62b5RaHUX+CVuWxlNdN9jHnyBzJhk6vy3hZo=
X-Content-Filtered-By: Mailman/MimeDel 2.1.30
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: KENNON J CONRAD via Cygwin <cygwin AT cygwin DOT com>
Reply-To: KENNON J CONRAD <kennonconrad AT comcast DOT net>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

Hello,
 
   I am not an experienced cygwin user but have been using it to compile code on Windows (gcc), so I may be leaving out some key details.  My issue is that for every log2 call in my code there is a divide that follows a log library call in the assembly code.  It appears to be related to these lines in math.h:
 
#if !defined(__cplusplus)
#define log2(x) (log (x) / _M_LN2)
#endif
 
My questions are:  If log(x) is used, wouldn't it be faster to multiply by constant (1/LN2) instead of divide by constant (LN2)?  And wouldn't it be even more efficient to compute log2 directly instead of computing the natural log and then converting it to log2?
 
I realize this is not a "bug", it just doesn't seem very optimal from an speed standpoint.
 
Best Regards,
 
Kennon Conrad
 
 

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