| Anonymous | Login | Signup for a new account | 2013-05-24 02:05 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||
| 0004752 | OCaml | OCaml general | public | 2009-03-19 13:56 | 2012-09-25 20:06 | |||
| Reporter | Christophe Troestler | |||||||
| Assigned To | xleroy | |||||||
| Priority | normal | Severity | feature | Reproducibility | N/A | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | 3.11.0 | |||||||
| Target Version | Fixed in Version | 3.13.0+dev | ||||||
| Summary | 0004752: copysign | |||||||
| Description | A _fast_ function [copysign : float -> float -> float] would be nice (working for all float values, including [nan]). It is more or less possible to write one with the standard library functions but it is not fast enough. | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0005858) Christophe Troestler (reporter) 2011-04-03 13:26 |
Note that it is also in the microsoft visual studio library under the name _copysign. http://msdn.microsoft.com/en-us/library/aa246720.aspx [^] |
|
(0005938) xleroy (administrator) 2011-05-29 17:48 |
How fast is "_fast_" ? If a call to a C function is fast enough, I see no problem implementing this function, either as a call to "copysign" if available, or through bit-twiddling in C. If inline assembly is expected, that's a lot more work... |
|
(0005939) Christophe Troestler (reporter) 2011-05-29 23:49 |
A C function is good. If it is not fast enough we can always bother you for the second solution later. ;) |
|
(0005970) xleroy (administrator) 2011-06-04 10:57 |
Implemented in SVN trunk (as a C function). Will go in release 3.13.0. |
|
(0005988) xleroy (administrator) 2011-06-07 19:22 |
A question occurs to me re: behavior w.r.t. NaN. The current implementation, like C99's copysign() function, has: copysign nan y = nan copysign x nan = x or -x depending on the sign bit of the nan. I wonder whether "copysign x nan = nan" would make more sense. At least that would make the copysign function fully specified. Any opinions in favor or against? |
|
(0005990) Christophe Troestler (reporter) 2011-06-07 21:15 |
IMHO, it is good to leave copysign as a way of extracting the sign of a nan.¹ (That behavior does not mean to me that is it not completely specified.) It is sometimes used; see for example ftp://ftp.win.ua.ac.be/pub/preprints/03/criticism.pdf [^] p.2. ¹ Despite the fact that there are surprises: copysign 1. ((±0.) /. (±0.)) = -1. |
|
(0005996) xleroy (administrator) 2011-06-09 11:38 |
All right, I'll leave copysign's behavior as it is today. Thanks for the feedback. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2009-03-19 13:56 | Christophe Troestler | New Issue | |
| 2009-04-29 15:42 | doligez | Status | new => acknowledged |
| 2011-04-03 13:26 | Christophe Troestler | Note Added: 0005858 | |
| 2011-05-29 14:19 | xleroy | Assigned To | => xleroy |
| 2011-05-29 17:48 | xleroy | Note Added: 0005938 | |
| 2011-05-29 23:49 | Christophe Troestler | Note Added: 0005939 | |
| 2011-06-04 10:57 | xleroy | Note Added: 0005970 | |
| 2011-06-04 10:57 | xleroy | Status | acknowledged => resolved |
| 2011-06-04 10:57 | xleroy | Resolution | open => fixed |
| 2011-06-04 10:57 | xleroy | Fixed in Version | => 3.13.0+dev |
| 2011-06-07 19:22 | xleroy | Note Added: 0005988 | |
| 2011-06-07 21:15 | Christophe Troestler | Note Added: 0005990 | |
| 2011-06-07 21:15 | Christophe Troestler | Status | resolved => feedback |
| 2011-06-07 21:15 | Christophe Troestler | Resolution | fixed => reopened |
| 2011-06-09 11:38 | xleroy | Note Added: 0005996 | |
| 2011-06-09 11:38 | xleroy | Status | feedback => resolved |
| 2011-06-09 11:38 | xleroy | Resolution | reopened => fixed |
| 2012-09-25 20:06 | xleroy | Status | resolved => closed |
| Copyright © 2000 - 2011 MantisBT Group |