Add public examples to many functions to std.math#6409
Add public examples to many functions to std.math#6409JackStouffer merged 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @JackStouffer! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + phobos#6409" |
| * $(TR $(TD $(LT)-1.0) $(TD $(NAN)) $(TD no) $(TD yes)) | ||
| * $(TR $(TD +$(INFIN)) $(TD -$(INFIN)) $(TD no) $(TD no)) | ||
| * $(TR $(TD $(LT)-1.0) $(TD -$(NAN)) $(TD no) $(TD yes)) | ||
| * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no) $(TD no)) |
There was a problem hiding this comment.
these where incorrect
std/math.d
Outdated
| * A `real`. | ||
| */ | ||
| real trunc(real x) @trusted nothrow @nogc | ||
| auto trunc(real x) @trusted |
There was a problem hiding this comment.
changed to auto to auto infer attributes like pure based on implementation without using template
There was a problem hiding this comment.
I feel the downside of not documenting the return type outweighs the benefit of attribute inference here.
There was a problem hiding this comment.
I added a note in the docs about the return type
b3b8486 to
44d7fb2
Compare
std/math.d
Outdated
| return core.stdc.math.llroundl(x); | ||
| else | ||
| assert(0, "lround not implemented"); | ||
| static assert(0, "lround not implemented"); |
There was a problem hiding this comment.
Looks like the remainder isn't available on Win32, but still run?
std\math.d(4908): Error: static assert: "lround not implemented"
Maybe we should roll a custom, "slow" implementation of it?
edit: probably due to it not being a template
wilzbach
left a comment
There was a problem hiding this comment.
Looks good. We just need to fix the CIs :/
| * $(LREF nearbyint) performs the same operation, but does | ||
| * not set the FE_INEXACT exception. | ||
| */ | ||
| real rint(real x) @safe pure nothrow @nogc { pragma(inline, true); return core.math.rint(x); } |
There was a problem hiding this comment.
So we have lround, nearbyint, round and rint which all perform almost the same function. That's not very "abstracted high-level" over C :/
| * $(TR $(TD -1.0) $(TD -$(INFIN)) $(TD yes) $(TD no)) | ||
| * $(TR $(TD $(LT)-1.0) $(TD $(NAN)) $(TD no) $(TD yes)) | ||
| * $(TR $(TD +$(INFIN)) $(TD -$(INFIN)) $(TD no) $(TD no)) | ||
| * $(TR $(TD $(LT)-1.0) $(TD -$(NAN)) $(TD no) $(TD yes)) |
There was a problem hiding this comment.
Could you add an explicit test for this? (i.e. that it's a negative nan)
There was a problem hiding this comment.
I have a test for this on line 3798, but because -real.nan != -real.nan there's really no way to test this
40571b1 to
52d7e6f
Compare
52d7e6f to
0cee769
Compare
0cee769 to
4b9d386
Compare
4b9d386 to
52b27fa
Compare
| * This is also known as "chop" rounding. | ||
| */ | ||
| real trunc(real x) @trusted nothrow @nogc | ||
| version(StdDdoc) |
There was a problem hiding this comment.
Ok, so apparently ret in ASM doesn't work with an auto return type. So we now have this mess.
…te needed for DragonFly. Caused trouble compiling phobos since dlang/phobos#6409 Phobos Compile Error: std/math.d(4598): Error: `pure` function `std.math.nearbyint` cannot call impure function `core.stdc.math.nearbyintl`
…te needed for DragonFly. Caused trouble compiling phobos since dlang/phobos#6409 Phobos Compile Error: std/math.d(4598): Error: `pure` function `std.math.nearbyint` cannot call impure function `core.stdc.math.nearbyintl`
No description provided.