3 ms·
By the way, I had a chance to check: and I was right with my guess. All six of those languages evaluate 1.0/4 to 0.25, exactly as expected. It might have taken
by sfpotter 3y ago
By the way, I had a chance to check: and I was right with my guess. All six of those languages evaluate 1.0/4 to 0.25, exactly as expected. It might have taken me 30 seconds or so to form my answer ;-) but that time was mostly spent parsing your question.
What languages don't evaluate 1.0/4 to 0.25? I checked OCaml (exception), node (0.25), Lua (0.25), Swift (0.25), sbcl (0.25), ... and then I got bored.
To me the expected behavior should be something like: for a binop between a float and an int, promote the int to float and do the floating point operation. Obviously there are corner cases here...