Skip to content

Commit 903046f

Browse files
string fixup
1 parent 34dcfc1 commit 903046f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/type/string.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
function string(x::DoubleFloat{T}) where {T<:IEEEFloat}
2-
!isfinite(HI(x)) && return string(HI(x))
2+
(!isfinite(HI(x)) || LO(x) === 0.0) && return string(HI(x))
3+
str = string(Float128(x))
4+
eat = findlast('e', str)
5+
isnothing(eat) && return str
6+
str[eat+2:end] === "00" && return(str[1:eat-1])
7+
8+
zat = eat - 1
9+
while str[zat] === '0'
10+
zat -= 1
11+
end
12+
if (str[zat] === '.') zat += 1 end
13+
str[1:zat] * str[eat:end]
14+
end
15+
16+
function string(x::DoubleFloat{T}) where {T<:IEEEFloat}
17+
(!isfinite(HI(x)) || LO(x) === 0.0) && return string(HI(x))
318
str = string(Float128(x))
419
if endswith("e+00", str)
520
str = str[1:end-4]
621
end
722
str
8-
end
23+
end
924

1025
function string(x::Complex{DoubleFloat{T}}) where {T<:IEEEFloat}
1126
xreal, ximag = reim(x)

0 commit comments

Comments
 (0)