@@ -37,7 +37,6 @@ include(depsjl_path)
37
37
const _buffer = fill (0x00 , 1024 )
38
38
39
39
import Base. promote_rule
40
- import Base. Grisu. DIGITS
41
40
42
41
# ############################################################################
43
42
# exception handling via global flags
@@ -195,6 +194,15 @@ julia> ldexp10(Dec64(15), 2)
195
194
"""
196
195
ldexp10 (x:: DecFP.DecimalFloatingPoint , n:: Integer )
197
196
197
+ # for compatibility with julia#29885
198
+ if isdefined (Base. Grisu, :getbuf )
199
+ getdigitsbuf () = Base. Grisu. getbuf ()
200
+ elseif isdefined (Base. Grisu, :DIGITSs )
201
+ getdigitsbuf () = Base. Grisu. DIGITSs[Threads. threadid ()]
202
+ else
203
+ getdigitsbuf () = Base. Grisu. DIGITS
204
+ end
205
+
198
206
for w in (32 ,64 ,128 )
199
207
BID = Symbol (string (" Dec" ,w))
200
208
Ti = eval (Symbol (string (" UInt" ,w)))
@@ -282,20 +290,20 @@ for w in (32,64,128)
282
290
return
283
291
end
284
292
285
- function Base. Printf. fix_dec (x:: $BID , n:: Int )
286
- if n > length (DIGITS ) - 1
287
- n = length (DIGITS ) - 1
293
+ function Base. Printf. fix_dec (x:: $BID , n:: Int , digits )
294
+ if n > length (digits ) - 1
295
+ n = length (digits ) - 1
288
296
end
289
297
rounded = round (ldexp10 (x, n), RoundNearestTiesAway)
290
298
if rounded == 0
291
- DIGITS [1 ] = UInt8 (' 0' )
299
+ digits [1 ] = UInt8 (' 0' )
292
300
return Int32 (1 ), Int32 (1 ), signbit (x)
293
301
end
294
302
tostring (rounded)
295
303
trailing_zeros = 0
296
304
i = 2
297
305
while _buffer[i] != UInt8 (' E' )
298
- DIGITS [i - 1 ] = _buffer[i]
306
+ digits [i - 1 ] = _buffer[i]
299
307
if _buffer[i] == UInt8 (' 0' )
300
308
trailing_zeros += 1
301
309
else
@@ -323,13 +331,13 @@ for w in (32,64,128)
323
331
return Int32 (len), Int32 (pt), neg
324
332
end
325
333
326
- function Base. Printf. ini_dec (x:: $BID , n:: Int )
327
- if n > length (DIGITS ) - 1
328
- n = length (DIGITS ) - 1
334
+ function Base. Printf. ini_dec (x:: $BID , n:: Int , digits )
335
+ if n > length (digits ) - 1
336
+ n = length (digits ) - 1
329
337
end
330
338
if x == 0
331
339
for i = 1 : n
332
- DIGITS [i] = UInt8 (' 0' )
340
+ digits [i] = UInt8 (' 0' )
333
341
end
334
342
return Int32 (1 ), Int32 (1 ), signbit (x)
335
343
end
@@ -339,18 +347,22 @@ for w in (32,64,128)
339
347
tostring (rounded)
340
348
i = 2
341
349
while _buffer[i] != UInt8 (' E' )
342
- DIGITS [i - 1 ] = _buffer[i]
350
+ digits [i - 1 ] = _buffer[i]
343
351
i += 1
344
352
end
345
353
while i <= n + 1
346
- DIGITS [i - 1 ] = UInt8 (' 0' )
354
+ digits [i - 1 ] = UInt8 (' 0' )
347
355
i += 1
348
356
end
349
357
pt = normalized_exponent + rounded_exponent - n + 2
350
358
neg = signbit (x)
351
359
return Int32 (n), Int32 (pt), neg
352
360
end
353
361
362
+ # compatibility with julia#30373
363
+ Base. Printf. fix_dec (x:: $BID , n:: Int ) = Base. Printf. fix_dec (x, n, getdigitsbuf ())
364
+ Base. Printf. ini_dec (x:: $BID , n:: Int ) = Base. Printf. ini_dec (x, n, getdigitsbuf ())
365
+
354
366
Base. fma (x:: $BID , y:: $BID , z:: $BID ) = nox (ccall (($ (bidsym (w," fma" )), libbid), $ BID, ($ BID,$ BID,$ BID), x, y, z))
355
367
Base. muladd (x:: $BID , y:: $BID , z:: $BID ) = fma (x,y,z) # faster than x+y*z
356
368
0 commit comments