colobot / colobot-data

Data files source for open-source Colobot: Gold Edition project developed by Epsitec and TerranovaTeam
http://colobot.info/
GNU General Public License v3.0
53 stars 46 forks source link

Document floating point remainders #86

Closed hexagonrecursion closed 3 weeks ago

hexagonrecursion commented 10 months ago

The docs say that % can only be used with int, but this works:

extern void object::New()
{
    float f = -4.5 % 2.75; // -1.75
    message(f);
}

It appears this was in the game since the initial commit: https://github.com/colobot/colobot/blob/a4c804b49ec872b71bd5a0167c3ad45704a3cc30/src/CBot/CBotVar.cpp#L1125-L1134

melex750 commented 10 months ago

% also works for the other undocumented numeric types; byte short char long double

hexagonrecursion commented 10 months ago

I do not think it makes sense to add this information to the docs for % unless the types themselves become a documented feature.

hexagonrecursion commented 3 weeks ago

Thanks, @tomangelo2