File tree Expand file tree Collapse file tree 2 files changed +2
-25
lines changed Expand file tree Collapse file tree 2 files changed +2
-25
lines changed Original file line number Diff line number Diff line change @@ -286,14 +286,8 @@ function mod(x::T, y::T) where T<:Integer
286
286
y == - 1 && return T (0 ) # avoid potential overflow in fld
287
287
return x - fld (x, y) * y
288
288
end
289
- function mod (x:: BitSigned , y:: Unsigned )
290
- remval = rem (x, y) # correct iff remval>=0
291
- return unsigned (remval + (remval< zero (remval))* y)
292
- end
293
- function mod (x:: Unsigned , y:: Signed )
294
- remval = signed (rem (x, y)) # remval>0 so correct iff y>0 or remval==0
295
- return remval + (! iszero (remval) && y< zero (y))* y
296
- end
289
+ mod (x:: BitSigned , y:: Unsigned ) = rem (y + unsigned (rem (x, y)), y)
290
+ mod (x:: Unsigned , y:: Signed ) = rem (y + signed (rem (x, y)), y)
297
291
mod (x:: T , y:: T ) where {T<: Unsigned } = rem (x, y)
298
292
299
293
# Don't promote integers for div/rem/mod since there is no danger of overflow,
Original file line number Diff line number Diff line change 358
358
end
359
359
end
360
360
end
361
- # exhaustive UInt8/Int8 tests for mixed signedness
362
- for f in (mod, rem)
363
- for i in - 128 : 127
364
- for j in 0 : 255
365
- if iszero (i)
366
- @test_throws DivideError f (UInt8 (j), Int8 (i))
367
- else
368
- @test f (UInt8 (j), Int8 (i)) == f (j, i)
369
- end
370
- if iszero (j)
371
- @test_throws DivideError f (Int8 (i), UInt8 (j))
372
- else
373
- @test f (Int8 (i), UInt8 (j)) == f (i,j)
374
- end
375
- end
376
- end
377
- end
378
361
end
379
362
380
363
@testset " Underscores in big_str" begin
You can’t perform that action at this time.
0 commit comments