@@ -340,7 +340,9 @@ for w in (32,64,128)
340
340
@eval Base.$ f (x:: $BID ) = @xchk (ccall (($ (bidsym (w,c)), libbid), $ BID, ($ BID,), x), DomainError, x, mask= INVALID)
341
341
end
342
342
343
- @eval Base. round (x:: $BID , :: RoundingMode{:Nearest} ) = @xchk (ccall (($ (bidsym (w," round_integral_nearest_even" )), libbid), $ BID, ($ BID,), x), DomainError, x, mask= INVALID)
343
+ for (r,c) in ((RoundingMode{:Nearest }," round_integral_nearest_even" ), (RoundingMode{:NearestTiesAway }," round_integral_nearest_away" ), (RoundingMode{:ToZero }," round_integral_zero" ), (RoundingMode{:Up }," round_integral_positive" ), (RoundingMode{:Down }," round_integral_negative" ))
344
+ @eval Base. round (x:: $BID , :: $r ) = @xchk (ccall (($ (bidsym (w,c)), libbid), $ BID, ($ BID,), x), DomainError, x, mask= INVALID)
345
+ end
344
346
345
347
for (f,c) in ((:(== )," quiet_equal" ), (:> ," quiet_greater" ), (:< ," quiet_less" ), (:(>= ), " quiet_greater_equal" ), (:(<= ), " quiet_less_equal" ))
346
348
@eval Base.$ f (x:: $BID , y:: $BID ) = nox (ccall (($ (bidsym (w,c)), libbid), Cint, ($ BID,$ BID), x, y) != 0 )
@@ -395,7 +397,6 @@ for w in (32,64,128)
395
397
Base. trunc (:: Type{$Ti′} , x:: $BID ) = @xchk (ccall (($ (bidsym (w," to_" ,i′str," _xint" )), libbid), $ Ti′, ($ BID,), x), InexactError, :trunc , $ BID, x, mask= INVALID | OVERFLOW)
396
398
Base. floor (:: Type{$Ti′} , x:: $BID ) = @xchk (ccall (($ (bidsym (w," to_" ,i′str," _xfloor" )), libbid), $ Ti′, ($ BID,), x), InexactError, :floor , $ BID, x, mask= INVALID | OVERFLOW)
397
399
Base. ceil (:: Type{$Ti′} , x:: $BID ) = @xchk (ccall (($ (bidsym (w," to_" ,i′str," _xceil" )), libbid), $ Ti′, ($ BID,), x), InexactError, :ceil , $ BID, x, mask= INVALID | OVERFLOW)
398
- Base. round (:: Type{$Ti′} , x:: $BID ) = @xchk (ccall (($ (bidsym (w," to_" ,i′str," _xrnint" )), libbid), $ Ti′, ($ BID,), x), InexactError, :round , $ BID, x, mask= INVALID | OVERFLOW)
399
400
Base. round (:: Type{$Ti′} , x:: $BID , :: RoundingMode{:NearestTiesAway} ) = @xchk (ccall (($ (bidsym (w," to_" ,i′str," _xrninta" )), libbid), $ Ti′, ($ BID,), x), InexactError, :round , $ BID, x, mask= INVALID | OVERFLOW)
400
401
Base. convert (:: Type{$Ti′} , x:: $BID ) = @xchk (ccall (($ (bidsym (w," to_" ,i′str," _xfloor" )), libbid), $ Ti′, ($ BID,), x), InexactError, :convert , $ BID, x)
401
402
Base.$ (Symbol (" $Ti′ " ))(x:: $BID ) = convert ($ Ti′, x)
@@ -418,7 +419,8 @@ Base.round(::Type{Integer}, x::DecimalFloatingPoint) = round(Int, x)
418
419
Base. round (:: Type{Integer} , x:: DecimalFloatingPoint , :: RoundingMode{:NearestTiesAway} ) = round (Int, x, RoundNearestTiesAway)
419
420
Base. convert (:: Type{Integer} , x:: DecimalFloatingPoint ) = convert (Int, x)
420
421
421
- Base. round (:: Type{T} , x:: DecimalFloatingPoint , :: RoundingMode{:Nearest} ) where {T<: Integer } = round (T, x)
422
+ Base. round (:: Type{T} , x:: DecimalFloatingPoint ) where {T<: Integer } = convert (T, round (x))
423
+ Base. round (:: Type{T} , x:: DecimalFloatingPoint , :: RoundingMode{:Nearest} ) where {T<: Integer } = convert (T, round (x, RoundNearest))
422
424
function Base. round (:: Type{T} , x:: DecimalFloatingPoint , :: RoundingMode{:NearestTiesUp} ) where {T<: Integer }
423
425
y = floor (T, x)
424
426
ifelse (x== y, y, copysign (floor (T, 2 * x- y), x))
0 commit comments