8282# and passed on the xmm registers, matching the x86_64 ABI for __float128.
8383const Cfloat128 = NTuple{2 ,VecElement{Float64}}
8484
85- struct Float128 <: AbstractFloat
86- data:: Cfloat128
87- function Float128 (data:: Cfloat128 )
88- new (data)
89- end
90- end
85+ primitive type Float128 <: AbstractFloat 128 end
86+ Float128 (data:: Cfloat128 ) = reinterpret (Float128, data)
87+
9188convert (:: Type{Float128} , x:: Number ) = Float128 (x)
9289
9390const ComplexF128 = Complex{Float128}
9491
95- Base. cconvert (:: Type{Cfloat128} , x:: Float128 ) = x. data
96- Base. cconvert (:: Type{Ref{Cfloat128}} , x:: Float128 ) = Ref {Cfloat128} (x. data)
97-
92+ Base. cconvert (:: Type{Cfloat128} , x:: Float128 ) = reinterpret (Cfloat128, x)
93+ Base. cconvert (:: Type{Ref{Cfloat128}} , x:: Float128 ) = Ref (Cfloat128 (x))
9894
9995# reinterpret
100- function reinterpret (:: Type{UInt128} , x:: Float128 )
101- hi = reinterpret (UInt64, x. data[2 ]. value)
102- lo = reinterpret (UInt64, x. data[1 ]. value)
103- UInt128 (hi) << 64 | lo
104- end
105- function reinterpret (:: Type{Float128} , x:: UInt128 )
106- fhi = reinterpret (Float64, (x >> 64 ) % UInt64)
107- flo = reinterpret (Float64, x % UInt64)
108- Float128 ((VecElement (flo), VecElement (fhi)))
109- end
11096reinterpret (:: Type{Unsigned} , x:: Float128 ) = reinterpret (UInt128, x)
11197reinterpret (:: Type{Signed} , x:: Float128 ) = reinterpret (Int128, x)
11298
113- reinterpret (:: Type{Int128} , x:: Float128 ) =
114- reinterpret (Int128, reinterpret (UInt128, x))
115- reinterpret (:: Type{Float128} , x:: Int128 ) =
116- reinterpret (Float128, reinterpret (UInt128, x))
117-
11899sign_mask (:: Type{Float128} ) = 0x8000_0000_0000_0000_0000_0000_0000_0000
119100exponent_mask (:: Type{Float128} ) = 0x7fff_0000_0000_0000_0000_0000_0000_0000
120101exponent_one (:: Type{Float128} ) = 0x3fff_0000_0000_0000_0000_0000_0000_0000
@@ -481,20 +462,10 @@ end
481462
482463function BigFloat (x:: Float128 ; precision= precision (BigFloat))
483464 if ! isfinite (x) || iszero (x)
484- @static if VERSION < v " 1.1"
485- return BigFloat (Float64 (x), precision)
486- else
487- return BigFloat (Float64 (x), precision= precision)
488- end
465+ return BigFloat (Float64 (x), precision= precision)
489466 end
490467
491- @static if VERSION < v " 1.1"
492- b = setprecision (BigFloat, max (precision,113 )) do
493- BigFloat ()
494- end
495- else
496- b = BigFloat (precision= max (precision,113 ))
497- end
468+ b = BigFloat (precision= max (precision,113 ))
498469
499470 y, k = frexp (x)
500471 b. exp = Clong (k)
@@ -514,16 +485,7 @@ function BigFloat(x::Float128; precision=precision(BigFloat))
514485 end
515486
516487 if precision < 113
517- @static if VERSION < v " 1.1"
518- b2 = setprecision (BigFloat, precision) do
519- BigFloat ()
520- end
521- ccall ((:mpfr_set , :libmpfr ), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32),
522- b2, b, MPFR. ROUNDING_MODE[])
523- return b2
524- else
525- return BigFloat (b, precision= precision)
526- end
488+ return BigFloat (b, precision= precision)
527489 else
528490 return b
529491 end
@@ -545,16 +507,7 @@ function Float128(x::BigFloat)
545507 z = reinterpret (Float128, UInt128 (0 ))
546508 end
547509
548- @static if VERSION < v " 1.1"
549- y = setprecision (BigFloat, prec) do
550- BigFloat ()
551- end
552- ccall ((:mpfr_set , :libmpfr ), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32),
553- y, x, MPFR. ROUNDING_MODE[])
554- else
555- y = BigFloat (x, precision= prec)
556- end
557-
510+ y = BigFloat (x, precision= prec)
558511 u = zero (UInt128)
559512 i = cld (prec, sizeof (MPFR. Limb)* 8 )
560513 j = 113
@@ -574,13 +527,7 @@ function BigInt(x::Float128)
574527 BigInt (BigFloat (x, precision= precision (Float128)))
575528end
576529function Float128 (x:: BigInt )
577- @static if VERSION < v " 1.1"
578- y = setprecision (BigFloat, precision (Float128)) do
579- BigFloat (x)
580- end
581- else
582- y = BigFloat (x, precision= precision (Float128))
583- end
530+ y = BigFloat (x, precision= precision (Float128))
584531 Float128 (y)
585532end
586533
0 commit comments