|
236 | 236 | # note: `isless`, and hence `<`, `min` and `max`, are automatically defined
|
237 | 237 |
|
238 | 238 | function decoration(x::BareInterval)
|
239 |
| - isnai(x) && return ill |
240 | 239 | isempty_interval(x) && return trv
|
241 | 240 | isunbounded(x) && return dac
|
242 | 241 | return com
|
|
302 | 301 | bareinterval(::Type{T}, x::Interval) where {T} = bareinterval(T, bareinterval(x))
|
303 | 302 | decoration(x::Interval) = x.decoration
|
304 | 303 |
|
| 304 | +""" |
| 305 | + setdecoration(x::Interval, d::Decoration) |
| 306 | +
|
| 307 | +Return the interval `bareinterval(x)` with decoration `d`, with the following |
| 308 | +exceptions: |
| 309 | +- if `d == ill`, then the output is an NaI |
| 310 | +- if `isempty_interval(bareinterval(x))` and `d != ill`, then the output has |
| 311 | +decoration `trv` |
| 312 | +- if `isunbounded(bareinterval(x))` and `d == com`, then the output has |
| 313 | +decoration `dac` |
| 314 | +
|
| 315 | +!!! danger |
| 316 | + Since misuse of this function can deeply corrupt code, its usage is |
| 317 | + **strongly discouraged**. |
| 318 | +
|
| 319 | +Implement the `setDec` function of the IEEE Standard 1788-2015 (Section 11.5.2). |
| 320 | +""" |
| 321 | +function setdecoration(x::Interval{T}, d::Decoration) where {T<:NumTypes} |
| 322 | + d == ill && return nai(T) |
| 323 | + bx = bareinterval(x) |
| 324 | + isempty_interval(bx) && return _unsafe_interval(bx, trv, isguaranteed(x)) |
| 325 | + (isunbounded(bx) & (d == com)) && return _unsafe_interval(bx, dac, isguaranteed(x)) |
| 326 | + return _unsafe_interval(bx, d, isguaranteed(x)) |
| 327 | +end |
| 328 | + |
305 | 329 | """
|
306 | 330 | isguaranteed(x::BareInterval)
|
307 | 331 | isguaranteed(x::Interval)
|
|
0 commit comments