@@ -37,7 +37,6 @@ include(depsjl_path)
3737const _buffer = fill (0x00 , 1024 )
3838
3939import Base. promote_rule
40- import Base. Grisu. DIGITS
4140
4241# ############################################################################
4342# exception handling via global flags
@@ -195,6 +194,15 @@ julia> ldexp10(Dec64(15), 2)
195194"""
196195ldexp10 (x:: DecFP.DecimalFloatingPoint , n:: Integer )
197196
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+
198206for w in (32 ,64 ,128 )
199207 BID = Symbol (string (" Dec" ,w))
200208 Ti = eval (Symbol (string (" UInt" ,w)))
@@ -282,20 +290,20 @@ for w in (32,64,128)
282290 return
283291 end
284292
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
288296 end
289297 rounded = round (ldexp10 (x, n), RoundNearestTiesAway)
290298 if rounded == 0
291- DIGITS [1 ] = UInt8 (' 0' )
299+ digits [1 ] = UInt8 (' 0' )
292300 return Int32 (1 ), Int32 (1 ), signbit (x)
293301 end
294302 tostring (rounded)
295303 trailing_zeros = 0
296304 i = 2
297305 while _buffer[i] != UInt8 (' E' )
298- DIGITS [i - 1 ] = _buffer[i]
306+ digits [i - 1 ] = _buffer[i]
299307 if _buffer[i] == UInt8 (' 0' )
300308 trailing_zeros += 1
301309 else
@@ -323,13 +331,13 @@ for w in (32,64,128)
323331 return Int32 (len), Int32 (pt), neg
324332 end
325333
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
329337 end
330338 if x == 0
331339 for i = 1 : n
332- DIGITS [i] = UInt8 (' 0' )
340+ digits [i] = UInt8 (' 0' )
333341 end
334342 return Int32 (1 ), Int32 (1 ), signbit (x)
335343 end
@@ -339,18 +347,22 @@ for w in (32,64,128)
339347 tostring (rounded)
340348 i = 2
341349 while _buffer[i] != UInt8 (' E' )
342- DIGITS [i - 1 ] = _buffer[i]
350+ digits [i - 1 ] = _buffer[i]
343351 i += 1
344352 end
345353 while i <= n + 1
346- DIGITS [i - 1 ] = UInt8 (' 0' )
354+ digits [i - 1 ] = UInt8 (' 0' )
347355 i += 1
348356 end
349357 pt = normalized_exponent + rounded_exponent - n + 2
350358 neg = signbit (x)
351359 return Int32 (n), Int32 (pt), neg
352360 end
353361
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+
354366 Base. fma (x:: $BID , y:: $BID , z:: $BID ) = nox (ccall (($ (bidsym (w," fma" )), libbid), $ BID, ($ BID,$ BID,$ BID), x, y, z))
355367 Base. muladd (x:: $BID , y:: $BID , z:: $BID ) = fma (x,y,z) # faster than x+y*z
356368
0 commit comments