-
Notifications
You must be signed in to change notification settings - Fork 0
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
misc math #494
Comments
|
EDIT: => nim-lang#16494 |
refs https://github.com/nim-lang/Nim/pull/16406/files#r549490523 |
|
eg: something along those lines (but adapted for the simpler case of abs) ## D20201228T203049
float copysignf(float x, float y)
{
union {float f; uint32_t i;} ux={x}, uy={y};
ux.i &= 0x7fffffff;
ux.i |= uy.i & 0x80000000;
return ux.f;
} |
|
|
|
|
there are other related functions, eg refs https://www.gnu.org/software/libc/manual/html_node/FP-Bit-Twiddling.html |
|
|
refs: nim-lang#16179 (comment) |
=> (preferably) make this actually true, or specify where this holds true or say simply this depends on compilers/arthitectures |
|
|
proc absUnsigned*(a: SomeSigned): auto =
type T = toUnsigned(type(a))
if a >= 0: cast[T](a)
else: cast[T](not(a)) + 1 avoids overflow errors |
^
(int pow) should also accepty<0
, in which case it uses 1/x ^ (-y)The text was updated successfully, but these errors were encountered: