-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from milankl/mk/restructure
Complete restructure
- Loading branch information
Showing
21 changed files
with
659 additions
and
1,434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
name = "StochasticRounding" | ||
uuid = "3843c9a1-1f18-49ff-9d99-1b4c8a8e97ed" | ||
authors = ["Milan Kloewer"] | ||
version = "0.7" | ||
authors = ["Milan Kloewer and StochasticRounding.jl contributors"] | ||
version = "0.8.0" | ||
|
||
[deps] | ||
BFloat16s = "ab4f0b2a-ad5b-11e8-123f-65d77653426b" | ||
DoubleFloats = "497a8b3b-efae-58df-a0af-a86822472b78" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
RandomNumbers = "e6cf234a-135c-5ec9-84dd-332b85af5143" | ||
|
||
[compat] | ||
BFloat16s = "0.1, 0.2, 0.3, 0.4" | ||
RandomNumbers = "^1.4" | ||
DoubleFloats = "1" | ||
Random = "1" | ||
RandomNumbers = "^1.4" | ||
julia = "1" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test","DifferentialEquations"] | ||
test = ["Test", "DifferentialEquations"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# from BFloat16s.jl#main (22/12/23) to be removed with next release of BFloat16s.jl | ||
function Base.nextfloat(f::BFloat16, d::Integer) | ||
|
||
F = typeof(f) | ||
fumax = reinterpret(Base.uinttype(F), F(Inf)) | ||
U = typeof(fumax) | ||
|
||
isnan(f) && return f | ||
fi = reinterpret(Int16, f) | ||
fneg = fi < 0 | ||
fu = unsigned(fi & typemax(fi)) | ||
|
||
dneg = d < 0 | ||
da = Base.uabs(d) | ||
if da > typemax(U) | ||
fneg = dneg | ||
fu = fumax | ||
else | ||
du = da % U | ||
if fneg ⊻ dneg | ||
if du > fu | ||
fu = min(fumax, du - fu) | ||
fneg = !fneg | ||
else | ||
fu = fu - du | ||
end | ||
else | ||
if fumax - fu < du | ||
fu = fumax | ||
else | ||
fu = fu + du | ||
end | ||
end | ||
end | ||
if fneg | ||
fu |= Base.sign_mask(F) | ||
end | ||
reinterpret(F, fu) | ||
end | ||
|
||
function Base.decompose(x::BFloat16)::NTuple{3,Int} | ||
isnan(x) && return 0, 0, 0 | ||
isinf(x) && return ifelse(x < 0, -1, 1), 0, 0 | ||
n = reinterpret(UInt16, x) | ||
s = (n & 0x007f) % Int16 | ||
e = ((n & 0x7f80) >> 7) % Int | ||
s |= Int16(e != 0) << 7 | ||
d = ifelse(signbit(x), -1, 1) | ||
s, e - 134 + (e == 0), d | ||
end | ||
|
||
BFloat16s.BFloat16(x::BigFloat) = BFloat16(Float32(x)) | ||
Base.BigFloat(x::BFloat16) = BigFloat(Float32(x)) | ||
|
||
Base.maxintfloat(::Type{BFloat16}) = reinterpret(BFloat16,0x4380) | ||
|
||
Base.round(x::BFloat16, r::RoundingMode{:ToZero}) = BFloat16(trunc(Float32(x))) | ||
Base.round(x::BFloat16, r::RoundingMode{:Down}) = BFloat16(floor(Float32(x))) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
dd229f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
dd229f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/97869
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: