.net - Why, In Java arithmetic, overflow or underflow will never throw an Exception? -


during java arithmetic operation , jvm not throw underflow or overflow exception. many time come across unexpected results , wondering went wrong.

while in case of .net technology have overflow , undeflow exception.

so question , why java design not throw exception during arithmetic operation

this combination of factors:

  1. the big languages prior java used unchecked arithmetic. well-known algorithms prone numerical overflow tended account potential overflow without relying on checked arithmetic.
  2. checked arithmetic introduces significant overhead in algorithms making heavy use of arithmetic instructions, put java @ substantial disadvantage benchmarks.
  3. some algorithms rely on silent numerical overflow/underflow. if arithmetic operations checked, rewriting these algorithms become non-trivial.
  4. checked arithmetic not necessary ensure memory safety (as opposed other jvm checks null pointers , array bounds).

the .net virtual execution environment (now part of ecma-335 standard) introduced separate instructions checked , unchecked arithmetic, allowing independently address performance , safety concerns of developers working in modern managed languages.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -