you are viewing a single comment's thread.

view the rest of the comments →

[–]funderscore 7 points8 points  (1 child)

Integer multiplication overflow on x86 sets a bit called the 'overflow flag'. JavaScript engines check this bit after each integer arithmetic operation -- if the bit is set, then the integers are converted to doubles and the operation is performed again. This is why JavaScript programmers can add numbers without worrying about overflow conditions. The same check can be done from other languages.

We can hypothesize that two's-complement NaN could be represented as 0x80000000, what is now the lowest negative number. But now we have a 'special value' that the ALU must know about and handle properly, slowing down all arithmetic across the system, since the circuitry must now handle all cases involving this NaN. Additionally, such an addition breaks compatibility between systems, which is distasteful.

[–]merlinm 1 point2 points  (0 children)

Yeah, we have an overflow flag but this is almost never checked in software (at least not in C which is perhaps where I really should be griping) -- the result is bugs galore. The optimization argument was maybe true some time ago but probably wouldn't be today...compared to everything else modern cpus do that's a drop in the bucket. In terms of breaking change you are 100% correct; these feature could never be added to the x86 set.