[0.16.51] Bonus of modules calculated with error

Bugs that are actually features.
sensenmann
Burner Inserter
Burner Inserter
Posts: 13
Joined: Tue Feb 28, 2017 5:04 pm
Contact:

[0.16.51] Bonus of modules calculated with error

Post by sensenmann »

AshenSwift freported on the mod forum of alien-module the following issue: https://mods.factorio.com/mod/alien-mod ... 000a5b9e22

After investigation i have the following problem with this code:

Code: Select all

for i = 1, 100, 1 do
    local levelbonus = i * 0.01
    data:extend({
        {
            [...]
            effect =
            {
                consumption = { bonus = levelbonus },
                speed = { bonus = levelbonus },
                productivity = { bonus = levelbonus }
            },
        },
    })
end
on level 29 the bonus is 28% and on level 58 the bonus is 57% for all other levels the bonus is correct. When i change levelbonus to:

Code: Select all

local levelbonus = i * 0.01001
everything works correctly. If this is not a bug then ignore the issue, this is most likely some floating point rounding issue IMHO.

I can even reproduce it in an online LUA console: https://repl.it/repls/ScornfulBeneficialChapter
Rseding91
Factorio Staff
Factorio Staff
Posts: 15714
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.16.51] Bonus of modules calculated with error

Post by Rseding91 »

Thanks for the report however there's nothing we can do about that :) That's just how floating point numbers work.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Not a bug”