diff --git a/src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlDecoderCore.cs b/src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlDecoderCore.cs index 7fb1775e0..8dcd47711 100644 --- a/src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlDecoderCore.cs +++ b/src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlDecoderCore.cs @@ -1565,8 +1565,10 @@ internal sealed class JxlDecoderCore : ImageDecoderCore, IDisposable } long totalBits = reader.TotalBitsConsumed; - this.AdvanceCodeStream(totalBits / JxlMath.BitsPerByte); - this.codestreamBitsAhead = totalBits % JxlMath.BitsPerByte; + (long div, long rem) = Math.DivRem(totalBits, JxlMath.BitsPerByte); + + this.AdvanceCodeStream(div); + this.codestreamBitsAhead = rem; this.gotTransformData = true; }