From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by sourceware.org (Postfix) with ESMTPS id 262E73858D33 for ; Wed, 7 Apr 2021 17:48:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 262E73858D33 Received: by mail-qt1-x832.google.com with SMTP id x9so14378114qto.8 for ; Wed, 07 Apr 2021 10:48:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id :disposition-notification-to:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=DzkMwmpbMzQZBYFHzJdz3UqMKDyFnB+RbbIJZhOW+Vc=; b=rQLZhe0vZ/FfVCjIuacv8PmLC7lAsg2VNd2na5DUd4BOr9PpvXRI6pW0w2MILGgwKG B4pNEdPsmep1Yqsjhs2PXnPoH80ZW/w91Rb8OXzU+NG5GuhTZl3xr7V7MZcuvosf6GxE XaQQKpgU12ayFnVnnfkHj65ssNo+MctFofKpH280pKm/hfldUzAhenzCzQFGCh79HgU0 8PDO+QNcp58ldCp0XcXOWRY6KNHWy2AaSy9+207QwY/ILDfhp4sWamft9dlTDQPByjvq JslUTVBLEMNqI7WiahfRBCuWIPtUZM4APJQ0+pAl/APf1MQFQ1hI9PDcAL+rzcFtAsut TtXQ== X-Gm-Message-State: AOAM5327QEh2TNuyiL1EvR1U4pBSnQC7CCPaicxqpuRmdw0ynGdIhUtb CgeBsegYArR/XQlhJeqEXD771djvyoDt X-Google-Smtp-Source: ABdhPJwPOx/PWlKG6OSKcniQ1fxbXuMq4GexLxiyuLkm4Nsgx8BOpIu653y3nbrME4w1kLGHtsGhoA== X-Received: by 2002:ac8:568d:: with SMTP id h13mr3762249qta.139.1617817702378; Wed, 07 Apr 2021 10:48:22 -0700 (PDT) Received: from [192.168.0.100] (186-247-153-111.user.veloxzone.com.br. [186.247.153.111]) by smtp.gmail.com with ESMTPSA id z24sm18488073qkz.65.2021.04.07.10.48.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Apr 2021 10:48:21 -0700 (PDT) To: libc-help@sourceware.org From: Rosivaldo Fernandes Alves Subject: Complex division implementation: arbitrary sign taking? Message-ID: Date: Wed, 7 Apr 2021 14:48:02 -0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=1.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GB_FREEMAIL_DISPTO, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 17:48:24 -0000 While trying to figure out how glibc implements complex division, I've found divtc3.c, where a division by zero is handled like written below. if (denom == 0.0 && (!isnan (a) || !isnan (b))) { x = copysignl (INFINITY, c) * a; y = copysignl (INFINITY, c) * b; } The other branches of the algorithm handle signs in a very sensible manner, but the lines above seem rather arbitrary. Why to take the sign of c for both parts? Why does d play not part at all? Thanks in advance. Rosivaldo.