SaintCoinach icon indicating copy to clipboard operation
SaintCoinach copied to clipboard

[Question] Magic bitwise operations

Open nikoTM opened this issue 2 years ago • 0 comments

Hi! Any chance you could elaborate on this code: https://github.com/Rogueadyn/SaintCoinach/blob/f969b441584688c02dde2fadac548c4a5aaa3faa/SaintCoinach/Xiv/WeatherRate.cs#L93

I stumbled upon this fascinating piece yesterday, still trying to understand what exactly is being done there:

var calcBase = (totalDays * 0x64) + increment;

var step1 = (calcBase << 0xB) ^ calcBase;
var step2 = (step1 >> 8) ^ step1;

return (int)(step2 % 0x64);

Thanks

nikoTM avatar Feb 25 '23 22:02 nikoTM