4 ms·
Different languages have different rules around some math operators, notably around order of operations and how % and / handle floating point values. There are
by banana_giraffe 5y ago
Different languages have different rules around some math operators, notably around order of operations and how % and / handle floating point values. There are much simpler expressions that will yield differences.
Also, you appear to be using Python 2, the results are different with any modern version of Python.
- banana_giraffe 5y agoAnd here are the two differences I think your expression is hitting on: Expression: 750/300 Python 2.7: 2 Python 3.9: 2.5 C: 2.000000 SQLite: 2 Node: 2.5 Java: 2 Go: 2 Expression: -123%10 Python 2.7: 7 Python 3.9: 7 C: -3.000000 SQLite: -3 Node: -3 Java: -3 Go: -3 There might be more. Though, there's a ton of needless obfuscation in your expression.
- unwind 5y agoCertainly not floating point results in C for either of those. All literals shown (750, 300, -123 and 10) are of type 'int', so the results would be, too.
- banana_giraffe 5y agoYep, I coerced the result to floating point in my harness. If anyone cares to look: https://pastebin.com/7tLrs28V https://pastebin.com/7tLrs28V I'm probably done, it's a mildly interesting side quest, but really, this is just reinforcing that different languages do things differently.