mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-31 00:58:26 +01:00
[MIRROR] Protect against floating-point inaccuracy in log() [MDB IGNORE] (#13600)
* Protect against floating-point inaccuracy in log() (#66875) This was causing issues with indexing icon slots (the main user of TOBITSHIFT). See BeeStation/BeeStation-Hornet#6842 for more details. Probably fixes #66197 and fixes #65652. (In all my tests, I could never get anything to show in suit_storage, whereas those bugs are reporting intermittent issues.) Originally made for BeeStation/BeeStation-Hornet#6842 (which also affects TG). * Protect against floating-point inaccuracy in log() Co-authored-by: David Walker <d0sboots@gmail.com>
This commit is contained in:
co-authored by
David Walker
parent
5de534a80a
commit
7806934960
@@ -117,7 +117,8 @@
|
||||
#define TORADIANS(degrees) ((degrees) * 0.0174532925)
|
||||
|
||||
/// Gets shift x that would be required the bitflag (1<<x)
|
||||
#define TOBITSHIFT(bit) ( log(2, bit) )
|
||||
/// We need the round because log has floating-point inaccuracy, and if we undershoot at all on list indexing we'll get the wrong index.
|
||||
#define TOBITSHIFT(bit) ( round(log(2, bit), 1) )
|
||||
|
||||
// Will filter out extra rotations and negative rotations
|
||||
// E.g: 540 becomes 180. -180 becomes 180.
|
||||
|
||||
Reference in New Issue
Block a user