Semantically, you are correct. However, if you go and read the V8 (or really, any performant implementation) source code, there is a separate integer type. Why? So that the JIT compiler can compile parts of the code to use integer arithmetic instead of floating point. Because it's just that much faster.
Yeah. We're not talking about an implementation detail of some VM or interpreter though. We're questioning whether some operator defined in the languages spec behaves as expected given the typing rules from the language spec.
And as you point out correctly, the semantics of the language should not depend on the implementation.
1
u/[deleted] Aug 26 '20
Semantically, you are correct. However, if you go and read the V8 (or really, any performant implementation) source code, there is a separate integer type. Why? So that the JIT compiler can compile parts of the code to use integer arithmetic instead of floating point. Because it's just that much faster.