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

fyi rounding modes that work with FloatNN #13

Open
JeffreySarnoff opened this issue Mar 27, 2021 · 0 comments
Open

fyi rounding modes that work with FloatNN #13

JeffreySarnoff opened this issue Mar 27, 2021 · 0 comments

Comments

@JeffreySarnoff
Copy link

JeffreySarnoff commented Mar 27, 2021

setrounding(Float64, MODE) works for these RoundingModes
RoundNearest, RoundUp, RoundDown, RoundToZero

setrounding(BigFloat, MODE) works for these RoundingModes
RoundNearest, RoundUp, RoundDown, RoundToZero, RoundFromZero

to emulate RoundFromZero on FloatNNs (similarly with (fn, x, y) and (fn, x, y, z)

function roundfromzero(fn, x::T) where {T}
   @nospecialize fn, x
    initialmode = rounding(T)
    roundingmode = signbit(x) ? RoundUp : RoundDown
    setrounding( T, roundingmode)
    result = fn(x)
    setrounding(T, initialmode)
    return result
end

If its not in the docs .. it should be (I have not looked).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant