Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensible Complex turns to NaN #1236

Closed
p6rt opened this issue Aug 28, 2009 · 5 comments
Closed

Sensible Complex turns to NaN #1236

p6rt opened this issue Aug 28, 2009 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Aug 28, 2009

Migrated from rt.perl.org#68848 (status was 'resolved')

Searchable as RT68848$

@p6rt
Copy link
Author

p6rt commented Aug 28, 2009

From @colomon

colomon​: rakudo​: say exp(3.0 * log(1i));
p6eval​: rakudo 0d4fe0​: OUTPUT«-1.83691e-16-1i␤»
colomon​: rakudo​: sub iPower($a, $b) { exp($b * log($a)) }; say iPower(1i, 3.0);
p6eval​: rakudo 0d4fe0​: OUTPUT«NaNNaNi␤»

(First result is correct, second is crazy.)

--
Solomon Foster​: colomon@​gmail.com
HarmonyWare, Inc​: http://www.harmonyware.com

@p6rt
Copy link
Author

p6rt commented Oct 28, 2009

From @moritz

On Fri Aug 28 14​:23​:50 2009, colomon@​gmail.com wrote​:

colomon​: rakudo​: say exp(3.0 * log(1i));
p6eval​: rakudo 0d4fe0​: OUTPUT«-1.83691e-16-1i␤»
colomon​: rakudo​: sub iPower($a, $b) { exp($b * log($a)) }; say
iPower(1i, 3.0);
p6eval​: rakudo 0d4fe0​: OUTPUT«NaNNaNi␤»

(First result is correct, second is crazy.)

22​:04 <@​moritz_> rakudo​: sub iPower($a, $b) { exp($b * log($a)) }; say
  iPower(1i, 3.0);
22​:04 <+p6eval> rakudo 6a43a3​: OUTPUT«-1.83697019872103e-16 + -1i␤»

Which is much better - just needs tests.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Oct 28, 2009

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 28, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S32-num/complex.t

commit c0e06f4657f82d1d2f99f47ef7bab76c660aff4e
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Wed Oct 28 21​:13​:02 2009 +0000

  [t/spec] tests for RT #​68848, complex powers wrapped in a subroutine
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;28940 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S32-num/complex.t b/t/spec/S32-num/complex.t
index e86ee90..168a66b 100644
--- a/t/spec/S32-num/complex.t
+++ b/t/spec/S32-num/complex.t
@@ -150,6 +150,16 @@ my $pi = 3.141592653589793238;
     is_approx(4.unpolar($pi),       -4,    "4.unpolar(pi)   == -4");
 }
 
+
+# used to be RT #68848
+{
+    is_approx exp(3.0 * log(1i)), -1.83697e-16-1i,
+              'exp(3.0 * log(1i))';
+    sub iPower($a, $b) { exp($b * log($a)) };
+    is_approx iPower(1i, 3.0), -1.83697e-16-1i, 'same as wrapped as sub';
+
+}
+
 done_testing;
 
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Oct 28, 2009

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Oct 28, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant