@@ -11,7 +11,7 @@ import Base: (*), +, -, /, <, <=, ==, ^, convert,
1111 acos, acosh, asin, asinh, atan, atanh, cosh, cos, sincos,
1212 exp, expm1, log, log2, log10, log1p, sin, sinh, sqrt,
1313 tan, tanh,
14- ceil, floor, trunc, round, fma,
14+ ceil, floor, trunc, round, fma, decompose,
1515 copysign, flipsign, max, min, hypot, abs,
1616 ldexp, frexp, modf, nextfloat, typemax, typemin, eps,
1717 isinf, isnan, isfinite, isinteger,
@@ -564,6 +564,17 @@ promote_rule(::Type{Float128}, ::Type{<:Integer}) = Float128
564564# widen(::Type{Float64}) = Float128
565565widen (:: Type{Float128} ) = BigFloat
566566
567+ function decompose (x:: Float128 ):: Tuple{Int128, Int, Int}
568+ isnan (x) && return 0 , 0 , 0
569+ isinf (x) && return ifelse (x < 0 , - 1 , 1 ), 0 , 0
570+ n = reinterpret (UInt128, x)
571+ s = (n & significand_mask (Float128)) % Int128
572+ e = ((n & exponent_mask (Float128)) >> 112 ) % Int
573+ s |= Int128 (e != 0 ) << 112
574+ d = ifelse (signbit (x), - 1 , 1 )
575+ s, e - 16495 + (e == 0 ), d
576+ end
577+
567578function Random. rand (rng:: AbstractRNG , s:: Random.SamplerTrivial{Random.CloseOpen01{Float128}} )
568579 u = rand (rng, UInt128)
569580 x = (reinterpret (Float128, u & Base. significand_mask (Float128)
0 commit comments