public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] The angle of a negative real is pi.
@ 2014-02-20 14:01 Jamison Hope
  2014-02-21 17:46 ` Per Bothner
  0 siblings, 1 reply; 2+ messages in thread
From: Jamison Hope @ 2014-02-20 14:01 UTC (permalink / raw)
  To: kawa@sourceware.org list

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] The angle of a negative real is pi.
  2014-02-20 14:01 [PATCH] The angle of a negative real is pi Jamison Hope
@ 2014-02-21 17:46 ` Per Bothner
  0 siblings, 0 replies; 2+ messages in thread
From: Per Bothner @ 2014-02-21 17:46 UTC (permalink / raw)
  To: Jamison Hope, kawa@sourceware.org list

On 02/20/2014 06:01 AM, Jamison Hope wrote:
> Fixes angle to return Math.PI on negative reals (including -inf.0).

Thanks - checked in.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-21 17:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-20 14:01 [PATCH] The angle of a negative real is pi Jamison Hope
2014-02-21 17:46 ` Per Bothner

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