I'm building a multi-client javascript game which includes very large flocks/swarms of units of located on a Cartesian plane - location, vectors and acceleration rates are all very finely tuned and constantly affected by each other and other actors - and as such are stored with javascript floats.
For various reasons (speed of game functions and bandwidth limits) much of the logic is done in parallel on client computers running identical games based on common inputs/instructions.
I'm concerned that some permutations of [browser/OS/hardware] will store floats differently in memory which will result in marginal drift between game versions.
The traditional issues with floats are well documented and I'm not concerned with using them - they're clearly the best degree of precision for my purposes. (e.g.
let x = .1;
let y = .2;
if (x+y == .3){
console.log("the same");
} else {
console.log("not the same: x+y = " + (x+y));
}
//output >>> "not the same: x+y = 0.30000000000000004"
I've looked around a bit and even well received answers such as this: How to deal with floating point number precision in JavaScript? don't cover my question exactly. This, and similar questions tend to deal with how to 'suppress rounding errors" or "ensure precision" etc.
I'm not looking for 'accuracy' as such - but consistency - thoughts welcome.
Yes, IEE 754 is well specified, and is referenced in the ECMA262 specification.