title: What happens if you divide by Zero on a computer?
body: <p>What happens if you divide by Zero on a Computer?</p>
  
  <p>In any given programming languange (I worked with, at least) this raises an error. 
  But why? Is it built in the language, that this is prohibited? Or will it compile, and the hardware will figure out that an error must be returned?</p>
  
  <p>I guess handling this by the language can only be done, if it is hard code, e.g. there is a line like <code>double z = 5.0/0.0;</code> If it is a function call, and the devisor is given from outside, the language could not even know that this is a division by zero (at least a compile time).</p>
  
  <pre><code>double divideByZero(double divisor){
      return 5.0/divisor;
  }
  </code></pre>
  
  <p>where divisor is called with <code>0.0</code>.</p>
  
  <p><strong>Update:</strong>
  According to the comments/answers it makes a difference whether you divide by <code>int 0</code> or <code>double 0.0</code>.
  I was not aware of that. This is interesting in itself and I'm interested in both cases.</p>
  
  <p>Also one answer is, that the CPU throws an error. Now, how is this done? Also in software (doesn't make sense on a CPU), or are there some circuits which recognize this? I guess this happens on the Arithmetic Logic Unit (ALU).</p>