Skip to content
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

Remove integer domain example that doesn't work #31298

Merged
merged 4 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions base/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@ to_power_type(x) = convert(Base._return_type(*, Tuple{typeof(x), typeof(x)}), x)
"\nConvert input to float.")))
@noinline throw_domerr_powbysq(::Integer, p) = throw(DomainError(p,
string("Cannot raise an integer x to a negative power ", p, '.',
"\nMake x a float by adding a zero decimal (e.g., 2.0^$p instead ",
"of 2^$p), or write 1/x^$(-p), float(x)^$p, or (x//1)^$p")))
"\nMake x or $p a float by adding a zero decimal ",
"(e.g., 2.0^$p or 2^$(float(p)) instead of 2^$p), ",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Keno I think this addresses your point about the error message suggestion. It adds a suggestion for 2^-1.0, as well as calling float on the exponent (i.e. 2^(float(p))) which should cover the literal and expression cases.

"or write 1/x^$(-p), float(x)^$p, x^float($p) or (x//1)^$p")))
@noinline throw_domerr_powbysq(::AbstractMatrix, p) = throw(DomainError(p,
string("Cannot raise an integer matrix x to a negative power ", p, '.',
"\nMake x a float matrix by adding a zero decimal ",
Expand Down
6 changes: 3 additions & 3 deletions doc/src/manual/noteworthy-differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ may trip up Julia users accustomed to MATLAB:
which grow `Vector`s much more efficiently than MATLAB's `a(end+1) = val`.
* The imaginary unit `sqrt(-1)` is represented in Julia as [`im`](@ref), not `i` or `j` as in MATLAB.
* In Julia, literal numbers without a decimal point (such as `42`) create integers instead of floating
point numbers. Arbitrarily large integer literals are supported. As a result, some operations
such as `2^-1` will throw a domain error as the result is not an integer (see [the FAQ entry on domain errors](@ref faq-domain-errors)
for details).
point numbers. As a result, some operations can throw
a domain error if they expect a float; for example, `julia> a = 1; 2^a` throws a domain error, as the
AnjoMan marked this conversation as resolved.
Show resolved Hide resolved
result is not an integer (see [the FAQ entry on domain errors](@ref faq-domain-errors) for details).
* In Julia, multiple values are returned and assigned as tuples, e.g. `(a, b) = (1, 2)` or `a, b = 1, 2`.
MATLAB's `nargout`, which is often used in MATLAB to do optional work based on the number of returned
values, does not exist in Julia. Instead, users can use optional and keyword arguments to achieve
Expand Down