@@ -112,11 +112,8 @@ Base.Rounding.setrounding(::Type{T}, r::RoundingMode) where {T<:DecimalFloatingP
112
112
for w in (32 ,64 ,128 )
113
113
BID = Symbol (string (" Dec" ,w))
114
114
Ti = Symbol (string (" UInt" ,w))
115
- @eval struct $ BID <: DecimalFloatingPoint
116
- x:: $Ti
117
- $ BID (x:: Number ) = convert ($ BID, x)
118
- Base. reinterpret (:: Type{$BID} , x:: $Ti ) = new (x)
119
- end
115
+ @eval primitive type $ BID <: DecimalFloatingPoint $ w end
116
+ $ BID (x:: Number ) = convert ($ BID, x)
120
117
121
118
@eval function $BID (x:: Real , mode:: RoundingMode )
122
119
setrounding ($ BID, mode) do
@@ -494,7 +491,7 @@ for w in (32,64,128)
494
491
Base. one (:: Union{Type{$BID},$BID} ) = $ (_parse (T, " 1" ))
495
492
Base. zero (:: Union{Type{$BID},$BID} ) = $ (_parse (T, " 0" ))
496
493
497
- Base. signbit (x:: $BID ) = $ (zero (Ti)) != $ (Ti (1 ) << (Ti (w - 1 ))) & x . x
494
+ Base. signbit (x:: $BID ) = $ (zero (Ti)) != $ (Ti (1 ) << (Ti (w - 1 ))) & reinterpret ( $ Ti, x)
498
495
Base. sign (x:: $BID ) = ifelse (isnan (x) || iszero (x), x, ifelse (signbit (x), $ (_parse (T, " -1" )), $ (_parse (T, " 1" ))))
499
496
500
497
Base. nextfloat (x:: $BID ) = nox (_nextfloat (x))
@@ -616,10 +613,9 @@ for w in (32,64,128)
616
613
end
617
614
end
618
615
619
- @eval Base. bswap (x:: $BID ) = reinterpret ($ BID, bswap (x . x ))
616
+ @eval Base. bswap (x:: $BID ) = reinterpret ($ BID, bswap (reinterpret ( $ Ti, x) ))
620
617
@eval Base. convert (:: Type{Float16} , x:: $BID ) = convert (Float16, convert (Float32, x))
621
618
@eval Base. Float16 (x:: $BID ) = convert (Float16, x)
622
- @eval Base. reinterpret (:: Type{$Ti} , x:: $BID ) = x. x
623
619
end # widths w
624
620
625
621
Base. round (x:: DecimalFloatingPoint , :: RoundingMode{:FromZero} ) = signbit (x) ? floor (x) : ceil (x)
0 commit comments