Skip to content

Commit

Permalink
abs computes magnitude for complex nums
Browse files Browse the repository at this point in the history
Instead of raising an error use C99 function to compute the magnitude instead. This is more useful and seems more correct as well.
  • Loading branch information
justinethier committed Sep 12, 2023
1 parent 0cad4ce commit 3e3f011
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bug Fixes
- Fix `exact` to properly handle complex numbers, including raising an error when passed `nan` or `inf` double values.
- Ensure the runtime properly differentiates between `+inf.0` and `-inf.0`. Thanks to jpellegrini for the bug report.
- jpellegrini reported that Cyclone returns `#f` when comparing complex numbers using operators other than `=`. Instead it is better to raise an error in these situations.
- lassik and jpellegrini reported that `abs` was incorrectly returning the real part of a complex number argument. Modified `abs` to return an error for complex numbers.
- lassik and jpellegrini reported that `abs` was incorrectly returning the real part of a complex number argument. Modified `abs` to properly handle complex numbers.
- jpellegrini fixed `(srfi 143)` so that the following are constants instead of procedures: `fx-width`, `fx-greatest`, and `fx-least`.
- Raise an error if `odd?` or `even?` is passed a decimal number. Thanks to jpellegrini for the bug report.
- Fix `read-line` to read entire lines that consist of more than 1022 bytes. Previously the function would only return partial data up to this limit. Thanks to Robby Zambito for the bug report.
Expand Down
3 changes: 2 additions & 1 deletion scheme/base.sld
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,8 @@
BIGNUM_CALL(mp_abs(&bignum_value(num), &bignum_value(bn)));
return_closcall1(data, k, bn);
} else if (is_object_type(num) && type_of(num) == complex_num_tag){
Cyc_rt_raise2(data, \"Unable to compute absolute value of complex number\", num);
make_double(d, cabs(((complex_num_type *)num)->value));
return_closcall1(data, k, &d);
} else {
make_double(d, fabs(((double_type *)num)->value));
return_closcall1(data, k, &d);
Expand Down

0 comments on commit 3e3f011

Please sign in to comment.