From: Jamison Hope <jrh@theptrgroup.com>
To: "kawa@sourceware.org list" <kawa@sourceware.org>
Subject: [PATCH] The angle of a negative real is pi.
Date: Thu, 20 Feb 2014 14:01:00 -0000 [thread overview]
Message-ID: <BE4A03DE-38BF-484A-80D5-D1A122C82AC0@theptrgroup.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 121 bytes --]
Fixes angle to return Math.PI on negative reals (including -inf.0).
--
Jamison Hope
The PTR Group
www.theptrgroup.com
[-- Attachment #2: real_angle.patch --]
[-- Type: application/octet-stream, Size: 1936 bytes --]
Index: gnu/math/ChangeLog
===================================================================
--- gnu/math/ChangeLog (revision 7819)
+++ gnu/math/ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2014-02-20 Jamison Hope <jrh@theptrgroup.com>
+
+ * RealNum.java (angle): The angle of a negative real is pi.
+
2014-02-16 Per Bothner <per@bothner.com>
* RealNum.java (isReal): New static method.
Index: gnu/math/RealNum.java
===================================================================
--- gnu/math/RealNum.java (revision 7819)
+++ gnu/math/RealNum.java (working copy)
@@ -11,8 +11,11 @@
{
public final RealNum re() { return this; }
public final RealNum im() { return IntNum.zero(); }
- public final RealNum angle() { return IntNum.zero(); }
+ public final RealNum angle() {
+ return isNegative() ? DFloNum.make(Math.PI) :IntNum.zero();
+ }
+
public static boolean isReal(Object value) {
return (value instanceof Number
&& (value instanceof RealNum || ! (value instanceof Numeric)));
Index: kawa/lib/ChangeLog
===================================================================
--- kawa/lib/ChangeLog (revision 7819)
+++ kawa/lib/ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2014-02-20 Jamison Hope <jrh@theptrgroup.com>
+
+ * numbers.scm (angle): The angle of a negative real is pi.
+
2014-02-17 Per Bothner <per@bothner.com>
* prim_syntax.scm (define-early-constant): New syntax.
Index: kawa/lib/numbers.scm
===================================================================
--- kawa/lib/numbers.scm (revision 7819)
+++ kawa/lib/numbers.scm (working copy)
@@ -239,7 +239,7 @@
(define (angle (x ::java.lang.Number)):: <real>
(if (gnu.math.Complex? x)
((->gnu.math.Complex x):angle)
- 0))
+ (if (< (x:doubleValue) 0) java.lang.Math:PI 0)))
(define (inexact (num :: java.lang.Number)) :: java.lang.Number
(gnu.kawa.functions.Arithmetic:toInexact num))
next reply other threads:[~2014-02-20 14:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-20 14:01 Jamison Hope [this message]
2014-02-21 17:46 ` Per Bothner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BE4A03DE-38BF-484A-80D5-D1A122C82AC0@theptrgroup.com \
--to=jrh@theptrgroup.com \
--cc=kawa@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).