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
copysign #4752
Comments
Comment author: @Chris00 Note that it is also in the microsoft visual studio library under the name _copysign. |
Comment author: @xavierleroy 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... |
Comment author: @Chris00 A C function is good. If it is not fast enough we can always bother you for the second solution later. ;) |
Comment author: @xavierleroy Implemented in SVN trunk (as a C function). Will go in release 3.13.0. |
Comment author: @xavierleroy A question occurs to me re: behavior w.r.t. NaN. The current implementation, like C99's copysign() function, has: |
Comment author: @Chris00 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. |
Comment author: @xavierleroy All right, I'll leave copysign's behavior as it is today. Thanks for the feedback. |
Original bug ID: 4752
Reporter: @Chris00
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2012-09-25T18:06:17Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: 3.11.0
Fixed in version: 3.13.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @glondu @hcarty @dbuenzli @Chris00
Bug 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.
The text was updated successfully, but these errors were encountered: