Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

fyi rounding modes that work with FloatNN #13

@JeffreySarnoff

Description

@JeffreySarnoff

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions