From 209fb06d6d34d287aa11a09a4ad0e9a5e777c154 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Mon, 28 Feb 2022 12:30:39 +0100 Subject: [PATCH] Binary float writing: Improve performance --- binary.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binary.lua b/binary.lua index 417f308..ea11a35 100644 --- a/binary.lua +++ b/binary.lua @@ -122,13 +122,13 @@ function write_float(write_byte, number, on_write, double) on_write(double) end local len = double and 6 or 2 - for index = len, 1, -1 do + for index = 1, len do mantissa = mantissa * 0x100 mantissa_bytes[index] = math_floor(mantissa) mantissa = mantissa % 1 end assert(mantissa == 0) - for index = 1, len do + for index = len, 1, -1 do write_byte(mantissa_bytes[index]) end write_byte(exponent_byte)