Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by h1439878.stratoserver.net (8.14.4/8.14.4/Debian-2ubuntu2.1) with ESMTP id v3E8Fohh011872 for ; Fri, 14 Apr 2017 10:15:51 +0200 Received: from relay.uni-heidelberg.de ([129.206.100.212]) by mx-ha.gmx.net (mxgmx014 [212.227.15.9]) with ESMTPS (Nemesis) id 1Mk078-1cJ37X1OUC-00kOwU for ; Fri, 14 Apr 2017 10:15:45 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay.uni-heidelberg.de (8.15.2/8.15.2) with ESMTP id v3E8FaRh013296; Fri, 14 Apr 2017 10:15:37 +0200 Received: from listserv (localhost [127.0.0.1]) by listserv.uni-heidelberg.de (Postfix) with ESMTP id DDC121269AF; Fri, 14 Apr 2017 10:15:36 +0200 (CEST) Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 16479647 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Fri, 14 Apr 2017 10:15:36 +0200 Delivered-To: LATEX-L@listserv.uni-heidelberg.de Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.119.212]) by listserv.uni-heidelberg.de (Postfix) with ESMTP id 421581229A6 for ; Fri, 14 Apr 2017 10:15:36 +0200 (CEST) Received: from smtp5.clear.net.nz (smtp5.clear.net.nz [203.97.33.68]) by relay2.uni-heidelberg.de (8.15.2/8.15.2) with ESMTP id v3E8FSWI032445 for ; Fri, 14 Apr 2017 10:15:32 +0200 Received: from mxin3-orange.clear.net.nz (lb1-srcnat.clear.net.nz [203.97.32.236]) by smtp5.clear.net.nz (CLEAR Net Mail) with ESMTP id <0OOE00CFW48KDJ10@smtp5.clear.net.nz> for LATEX-L@listserv.uni-heidelberg.de; Fri, 14 Apr 2017 20:14:48 +1200 (NZST) Received: from 118-92-82-172.dsl.dyn.ihug.co.nz (HELO [127.0.0.1]) ([118.92.82.172]) by smtpin3.clear.net.nz with ESMTP; Fri, 14 Apr 2017 20:14:45 +1200 MIME-version: 1.0 Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 7bit X-Antivirus: avast! (VPS 170413-2, 14/04/2017), Outbound message X-Antivirus-Status: Clean References: <58E07974.2090404@clear.net.nz> <332a169f-e924-44af-3325-f633d3065ad4@gmail.com> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 Message-ID: <58F084F5.70106@clear.net.nz> Date: Fri, 14 Apr 2017 20:14:45 +1200 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Andrew Parsloe Subject: Re: distinguishing -0 in l3fp To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <332a169f-e924-44af-3325-f633d3065ad4@gmail.com> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:B6vWbnwaPb4=:gKBf2whIApTNwYi7umGIZpAXWJ SpBzZ8XuJpcv+hKY9t3GPmEpi/uB6sVvN9XpXM36t1YYnZ3ra1XHZEf6YCZcFpn5ZrKwETBV5 xy4ed3hSC9QQgLlrJOMki4n1Cu2b83FwXYITzxKiXHe/yCD7nT3X56QAImH7zVus+V8bj8EGU qsn9V5e85un5j83Sg+0aoOl8NfH01oXbwTrKgAWf+7nYxeluenV936L/Jn4IrK8q2TGpQKozF siKx7ZoZfrN6L+7MhDTxAD552n/rrJDbImcDM1aDd9dBE2L0zyf8eO7MfQDxrea2wY9VcilVk O0z2JR17pgdxNWrtG41OXCJ6oRGxoHncmFlugPGCAzAAHaJBLafV+J7JnNpO3qRXmUOB9Bi1S MHHgzctyDq+mWyEexinGgqjozykll1luynseSfYPagCbVFbCF7Y2XeitJKM1/L2sGDj106LWo Gzp7oIf9YWMnwsLib3SDG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LR8 VVmcwKQ7aJ4F5Xr4Xo2+w4Rz+GwEt2WxkqtHdl7/AwTPDiyzRFaN8B+/ZOxYLXw== X-UI-Loop:V01:WrbcbuAhAXw=:h2yS2dAXgKaocTnQk8/HPQfqwo7j1NNshYVfYTSXyic= X-UI-Out-Filterresults: notjunk:1;V01:K0:KJDMBN+0z3M=:u5OKRGVuBSjWeF/L5HrDLX T9X26GOTwjwYfmR8N4P/H2JUThU0XIhjM3pKWdt+CE0cv9J9vKu6Cb8YdmeFpqPqIQorWYAlz IS6Pa0MbJ6VEzx98YhxFIzUgEWfgCNJJAjP64fx4rjDKJ+ZcDlL5YC618Gh/Z7yhpOSQtVXxJ 42EEy0Phsvj2xuRZxpU3SNjXTE0deTuPsCfcCv4NPdDj5gVu9UYktzNvXHh1oS7vdlkkSnm0g rLWAVPUTLwXGR1vNLpTXgVEiKc3hpVcI0iNuyk4os+RdAlbrRtGfNO7mWmr0zYJ4WyVBcwvbS aWCkG/RmMjbejLAZICMTXXrkfMc02JS0DjUy+BDIX+MzNVpZeqOWXq2bbBWIudGsh5c4VM+vt sDBP+dchrZMO155uHiuX5rrop4QJO7KvjPbJzBA8HeMktf/i48JQolIDigTnN92pE/rJKQiSf eRwzDRB4Sg== X-Scanned-By: MIMEDefang 2.71 on 85.214.41.38 Status: R X-Status: X-Keywords: X-UID: 7959 On 14/04/2017 2:28 p.m., Bruno Le Floch wrote: > On 04/02/2017 12:09 AM, Andrew Parsloe wrote: >> Is there a simple way to distinguish -0 from 0 in l3fp? >> >> I had been aligning left in a table a column of sines, +0 or -0 followed >> by decimal point & digits. By adding an \hphantom{-} before the positive >> numbers, they aligned nicely on the decimal point in the column, but >> then along came -0. The simple conditional, "if !(number < 0) add >> phantom", added the phantom and the column aligned like >> 0 >> 0.5878 >> -0 >> -0.5878 >> etc. >> In the absence of formatted printing of numbers, -0 is a problem. Even a >> built-in test for -0 would ease matters, since in any kind of formatted >> printing of numbers 0 and -0 will generally require different handling. >> >> As it is, I've had to test each fp for whether it is zero; if it is I >> convert to a tl variable and test whether that is -0. This is clumsy. >> Hence my opening question. >> >> Andrew > > Sorry for the delay. > > One option is to normalize -0 to +0 by adding +0. Namely, number+0 is > equal to number for any non-zero number and is +0 for both +0 and -0. > > Another option is to compute 1/number after disabling the > "division-by-zero" trap, and test whether that's +inf or -inf, but > that's more complicated than the tl test you're doing. > > A better option is that I should add a "copysign" function, that is in > the IEEE standard: copysign(1,x) gives +1 or -1 depending on the sign > bit of x (so in particular this distinguishes +0 and -0). > > For your specific use case I would use \fp_to_tl:n then test whether the > first character (\str_head:n) is "-" or not. This also covers nan properly. > > Bruno > Ah, the "add +0" suggestion is helpful, and certainly simpler than what I was doing. You implemented, very promptly, an earlier suggestion of mine about adding "sign" to l3fp. Thank you. In the course of dealing with the above problem I noticed that sign(-0) = -0. I presume this is the expected result. (I was rather hoping sign(x) might evaluate to one of the *three* values -1, 0, 1.) Andrew --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus