https://github.com/JuliaLang/julia
Revision d24316ac6465302aa32d9616ab731499c3734bce authored by Nathan Zimmerberg on 07 February 2024, 15:53:14 UTC, committed by GitHub on 07 February 2024, 15:53:14 UTC
Fixes #51731 and #51730 

Also fixes one of the previously broken tests:
```julia
@test_broken Rational{Int64}(UInt(1), typemin(Int32)) == Int64(1) // Int64(typemin(Int32))
```

This PR ensures the `Rational{T}` constructor with concrete `T` will
only throw if the final numerator and denominator cannot be represented
by `T`, or are both zero.

If the `T` in `Rational{T}` is not concrete, this PR tries to ensure the
numerator and denominator are promoted to the same type.
This means `-1*Rational{Integer}(-1, 0x01) == 1` doesn't throw now. A
side effect of this is that `Rational{Integer}(Int8(-1), 0x01)` now
throws.

Also, related to
<https://github.com/JuliaLang/julia/pull/25702#issuecomment-359821951>,
now `divgcd` doesn't change the types of its inputs and can handle
`typemin`, but it still throws a `DivideError` if both inputs are zero.
1 parent 736eeda
History
Tip revision: d24316ac6465302aa32d9616ab731499c3734bce authored by Nathan Zimmerberg on 07 February 2024, 15:53:14 UTC
Fix Int8(-128) // Int8(-128) (#51944)
Tip revision: d24316a
File Mode Size
.devcontainer
.github
base
cli
contrib
deps
doc
etc
src
stdlib
test
.buildkite-external-version -rw-r--r-- 5 bytes
.clang-format -rw-r--r-- 3.3 KB
.clangd -rw-r--r-- 114 bytes
.codecov.yml -rw-r--r-- 52 bytes
.git-blame-ignore-revs -rw-r--r-- 371 bytes
.gitattributes -rw-r--r-- 65 bytes
.gitignore -rw-r--r-- 571 bytes
.mailmap -rw-r--r-- 12.7 KB
CITATION.bib -rw-r--r-- 513 bytes
CITATION.cff -rw-r--r-- 940 bytes
CONTRIBUTING.md -rw-r--r-- 23.4 KB
HISTORY.md -rw-r--r-- 372.8 KB
LICENSE.md -rw-r--r-- 1.3 KB
Make.inc -rw-r--r-- 55.9 KB
Makefile -rw-r--r-- 30.2 KB
NEWS.md -rw-r--r-- 11.5 KB
README.md -rw-r--r-- 7.4 KB
THIRDPARTY.md -rw-r--r-- 3.9 KB
VERSION -rw-r--r-- 11 bytes
julia.spdx.json -rw-r--r-- 37.8 KB
pkgimage.mk -rw-r--r-- 5.9 KB
sysimage.mk -rw-r--r-- 4.2 KB
typos.toml -rw-r--r-- 78 bytes

README.md

back to top