* Problem diving complex numbers
@ 2005-04-27 19:10 Jean Crepeau
2005-04-29 22:49 ` Kevin Ryde
0 siblings, 1 reply; 2+ messages in thread
From: Jean Crepeau @ 2005-04-27 19:10 UTC (permalink / raw)
[-- Attachment #1.1: Type: text/plain, Size: 232 bytes --]
There appears to be a bug in the 1.6.x releases of guile which wasn't
there in the 1.4.1 (and probably other versions before). Simply doing
(/ 0-1i)
will result in #.##.#i instead of the expected
0.0+1.0i
Jean ;-)
[-- Attachment #1.2: Type: text/html, Size: 562 bytes --]
[-- Attachment #2: Type: text/plain, Size: 137 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Problem diving complex numbers
2005-04-27 19:10 Problem diving complex numbers Jean Crepeau
@ 2005-04-29 22:49 ` Kevin Ryde
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Ryde @ 2005-04-29 22:49 UTC (permalink / raw)
Cc: bug-guile
[-- Attachment #1: Type: text/plain, Size: 410 bytes --]
Jean Crepeau <crep@crep.dhs.org> writes:
>
> There appears to be a bug in the 1.6.x releases of guile which wasn't
> there in the 1.4.1 (and probably other versions before).
Yep, but those versions are prone to overflow when re or im is above
sqrt(DBL_MAX).
> Simply doing
>
> (/ 0-1i)
>
> will result in #.##.#i
Thanks. Looks like nobody ever divided by -i before :). I think it's
meant to be like:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: numbers.c.cdiv.diff --]
[-- Type: text/x-patch, Size: 982 bytes --]
--- numbers.c.~1.135.2.20.~ 2005-02-21 09:50:34.000000000 +1100
+++ numbers.c 2005-04-29 14:19:10.535828592 +1000
@@ -3738,7 +3738,7 @@
} else if (SCM_COMPLEXP (x)) {
double r = SCM_COMPLEX_REAL (x);
double i = SCM_COMPLEX_IMAG (x);
- if (r <= i) {
+ if (fabs(r) <= fabs(i)) {
double t = r / i;
double d = i * (1.0 + t * t);
return scm_make_complex (t / d, -1.0 / d);
@@ -3782,7 +3782,7 @@
{
double r = SCM_COMPLEX_REAL (y);
double i = SCM_COMPLEX_IMAG (y);
- if (r <= i) {
+ if (fabs(r) <= fabs(i)) {
double t = r / i;
double d = i * (1.0 + t * t);
return scm_make_complex ((a * t) / d, -a / d);
@@ -3873,7 +3873,7 @@
} else if (SCM_COMPLEXP (y)) {
double ry = SCM_COMPLEX_REAL (y);
double iy = SCM_COMPLEX_IMAG (y);
- if (ry <= iy) {
+ if (fabs(ry) <= fabs(iy)) {
double t = ry / iy;
double d = iy * (1.0 + t * t);
return scm_make_complex ((rx * t + ix) / d, (ix * t - rx) / d);
[-- Attachment #3: Type: text/plain, Size: 137 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-04-29 22:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-27 19:10 Problem diving complex numbers Jean Crepeau
2005-04-29 22:49 ` Kevin Ryde
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).