• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37527

pending completion
#37527

push

local

web-flow
make `IRShow.method_name` inferrable (#49607)

18 of 18 new or added lines in 3 files covered. (100.0%)

68710 of 81829 relevant lines covered (83.97%)

33068903.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.17
/base/ryu/fixed.jl
1
function writefixed(buf, pos, v::T,
1,395✔
2
    precision=-1, plus=false, space=false, hash=false,
3
    decchar=UInt8('.'), trimtrailingzeros=false) where {T <: Base.IEEEFloat}
4
    @assert 0 < pos <= length(buf)
2,529✔
5
    startpos = pos
×
6
    x = Float64(v)
×
7
    pos = append_sign(x, plus, space, buf, pos)
2,572✔
8

9
    # special cases
10
    if x == 0
1,304✔
11
        buf[pos] = UInt8('0')
90✔
12
        pos += 1
90✔
13
        if precision > 0 && !trimtrailingzeros
90✔
14
            buf[pos] = decchar
87✔
15
            pos += 1
87✔
16
            for _ = 1:precision
174✔
17
                buf[pos] = UInt8('0')
168✔
18
                pos += 1
168✔
19
            end
249✔
20
        elseif hash
3✔
21
            buf[pos] = decchar
×
22
            pos += 1
×
23
        end
24
        return pos
90✔
25
    elseif isnan(x)
1,214✔
26
        buf[pos] = UInt8('N')
5✔
27
        buf[pos + 1] = UInt8('a')
5✔
28
        buf[pos + 2] = UInt8('N')
5✔
29
        return pos + 3
5✔
30
    elseif !isfinite(x)
1,209✔
31
        buf[pos] = UInt8('I')
7✔
32
        buf[pos + 1] = UInt8('n')
7✔
33
        buf[pos + 2] = UInt8('f')
7✔
34
        return pos + 3
7✔
35
    end
36

37
    bits = Core.bitcast(UInt64, x)
1,202✔
38
    mant = bits & MANTISSA_MASK
1,202✔
39
    exp = Int((bits >> 52) & EXP_MASK)
1,202✔
40

41
    if exp == 0
1,202✔
42
        e2 = 1 - 1023 - 52
×
43
        m2 = mant
×
44
    else
45
        e2 = exp - 1023 - 52
1,202✔
46
        m2 = (Int64(1) << 52) | mant
1,202✔
47
    end
48
    nonzero = false
1,202✔
49
    if e2 >= -52
1,202✔
50
        idx = e2 < 0 ? 0 : indexforexp(e2)
1,029✔
51
        p10bits = pow10bitsforindex(idx)
1,025✔
52
        len = lengthforindex(idx)
1,025✔
53
        i = len - 1
1,025✔
54
        while i >= 0
3,130✔
55
            j = p10bits - e2
2,105✔
56
            #=@inbounds=# mula, mulb, mulc = POW10_SPLIT[POW10_OFFSET[idx + 1] + i + 1]
2,105✔
57
            digits = mulshiftmod1e9(m2 << 8, mula, mulb, mulc, j + 8)
2,105✔
58
            if nonzero
2,105✔
59
                pos = append_nine_digits(digits, buf, pos)
56✔
60
            elseif digits != 0
2,049✔
61
                olength = decimallength(digits)
2,050✔
62
                pos = append_n_digits(olength, digits, buf, pos)
1,025✔
63
                nonzero = true
×
64
            end
65
            i -= 1
2,105✔
66
        end
2,105✔
67
    end
68
    if !nonzero
1,202✔
69
        buf[pos] = UInt8('0')
177✔
70
        pos += 1
177✔
71
    end
72
    hasfractional = false
1,202✔
73
    if precision > 0 || hash
1,243✔
74
        buf[pos] = decchar
1,187✔
75
        pos += 1
1,187✔
76
        hasfractional = true
×
77
    end
78
    if e2 < 0
1,202✔
79
        idx = div(-e2, 16)
1,198✔
80
        blocks = div(precision, 9) + 1
1,198✔
81
        roundUp = 0
×
82
        i = 0
×
83
        if blocks <= MIN_BLOCK_2[idx + 1]
1,198✔
84
            i = blocks
×
85
            for _ = 1:precision
×
86
                buf[pos] = UInt8('0')
×
87
                pos += 1
×
88
            end
×
89
        elseif i < MIN_BLOCK_2[idx + 1]
1,198✔
90
            i = MIN_BLOCK_2[idx + 1]
×
91
            for _ = 1:(9 * i)
×
92
                buf[pos] = UInt8('0')
×
93
                pos += 1
×
94
            end
×
95
        end
96
        while i < blocks
1,213✔
97
            j = 120 + (-e2 - 16 * idx)
1,213✔
98
            p = POW10_OFFSET_2[idx + 1] + UInt32(i) - MIN_BLOCK_2[idx + 1]
1,213✔
99
            if p >= POW10_OFFSET_2[idx + 2]
1,213✔
100
                for _ = 1:(precision - 9 * i)
×
101
                    buf[pos] = UInt8('0')
×
102
                    pos += 1
×
103
                end
×
104
                break
×
105
            end
106
            #=@inbounds=# mula, mulb, mulc = POW10_SPLIT_2[p + 1]
1,213✔
107
            digits = mulshiftmod1e9(m2 << 8, mula, mulb, mulc, j + 8)
1,213✔
108
            if i < blocks - 1
1,213✔
109
                pos = append_nine_digits(digits, buf, pos)
15✔
110
            else
111
                maximum = precision - 9 * i
1,198✔
112
                lastDigit = 0
×
113
                k = 0
×
114
                while k < 9 - maximum
9,703✔
115
                    # global digits, lastDigit, k
116
                    lastDigit = digits % 10
15,812✔
117
                    digits = div(digits, 10)
15,812✔
118
                    k += 1
8,505✔
119
                end
8,505✔
120
                if lastDigit != 5
2,396✔
121
                    roundUp = lastDigit > 5
2,206✔
122
                else
123
                    requiredTwos = -e2 - precision - 1
95✔
124
                    trailingZeros = requiredTwos <= 0 || (requiredTwos < 60 && pow2(m2, requiredTwos))
190✔
125
                    roundUp = trailingZeros ? 2 : 1
95✔
126
                end
127
                if maximum > 0
1,198✔
128
                    pos = append_c_digits(maximum, digits, buf, pos)
2,298✔
129
                end
130
                break
1,198✔
131
            end
132
            i += 1
15✔
133
        end
15✔
134
        if roundUp != 0
1,293✔
135
            roundPos = pos
×
136
            dotPos = 1
×
137
            while true
578✔
138
                roundPos -= 1
578✔
139
                if roundPos == (startpos - 1) || (buf[roundPos] == UInt8('-')) || (plus && buf[roundPos] == UInt8('+')) || (space && buf[roundPos] == UInt8(' '))
1,153✔
140
                    buf[roundPos + 1] = UInt8('1')
5✔
141
                    if dotPos > 1
5✔
142
                        buf[dotPos] = UInt8('0')
5✔
143
                        buf[dotPos + 1] = decchar
5✔
144
                        hasfractional = true
×
145
                    end
146
                    buf[pos] = UInt8('0')
5✔
147
                    pos += 1
5✔
148
                    break
×
149
                end
150
                c = roundPos > 0 ? buf[roundPos] : 0x00
573✔
151
                if c == decchar
573✔
152
                    dotPos = roundPos
×
153
                    continue
19✔
154
                elseif c == UInt8('9')
554✔
155
                    buf[roundPos] = UInt8('0')
74✔
156
                    roundUp = 1
×
157
                    continue
74✔
158
                else
159
                    if roundUp == 2 && UInt8(c) % 2 == 0
615✔
160
                        break
×
161
                    end
162
                    buf[roundPos] = c + 1
480✔
163
                    break
480✔
164
                end
165
            end
1,291✔
166
        end
167
    else
168
        for _ = 1:precision
4✔
169
            buf[pos] = UInt8('0')
×
170
            pos += 1
×
171
        end
×
172
    end
173
    if trimtrailingzeros && hasfractional
1,202✔
174
        while buf[pos - 1] == UInt8('0')
97✔
175
            pos -= 1
67✔
176
        end
67✔
177
        if buf[pos - 1] == decchar && !hash
30✔
178
            pos -= 1
13✔
179
        end
180
    end
181
    return pos
1,202✔
182
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc