1 / 0

Python

print 1 / 0
Traceback (most recent call last):
  File "tmp.py", line 1, in <module>
    print 1 / 0
ZeroDivisionError: integer division or modulo by zero

Ruby

puts 1 / 0
tmp.rb:1:in `/': divided by 0 (ZeroDivisionError)
      from tmp.rb:1:in `<main>'

JavaScript

console.log(1 / 0);
Infinity

Perl

print 1 / 0;
Illegal division by zero at tmp.pl line 1.

Java

public class Tmp {
    public static void main(String[] args){
        System.out.println(1 / 0);
    }
}
Exception in thread "main" java.lang.ArithmeticException: / by zero
      at Tmp.main(Tmp.java:3)

C++

#include <stdio.h>
int main(){
  printf("%d\n", 1 / 0);
}
tmp.cpp: In function 'int main()':
tmp.cpp:3:22: warning: division by zero [-Wdiv-by-zero]

Clojure

(print (/ 1 0))
Exception in thread "main" java.lang.ArithmeticException: Divide by zero
      at clojure.lang.Numbers.divide(Numbers.java:156)
      at clojure.lang.Numbers.divide(Numbers.java:3691)
      at user$eval1.invoke(tmp.clj:1)
      at clojure.lang.Compiler.eval(Compiler.java:6511)
      at clojure.lang.Compiler.load(Compiler.java:6952)
      at clojure.lang.Compiler.loadFile(Compiler.java:6912)
      at clojure.main$load_script.invoke(main.clj:283)
      at clojure.main$script_opt.invoke(main.clj:343)
      at clojure.main$main.doInvoke(main.clj:427)
      at clojure.lang.RestFn.invoke(RestFn.java:408)
      at clojure.lang.Var.invoke(Var.java:415)
      at clojure.lang.AFn.applyToHelper(AFn.java:161)
      at clojure.lang.Var.applyTo(Var.java:532)
      at clojure.main.main(main.java:37)

Scheme

(display (/ 1 0))
+inf.0

Smalltalk

1 / 0
Object: 1 error: The program attempted to divide a number by zero
ZeroDivide(Exception)>>signal (ExcHandling.st:254)
SmallInteger(Number)>>zeroDivide (SysExcept.st:1385)
SmallInteger>>/ (SmallInt.st:277)
UndefinedObject>>executeStatements (tmp.st:1)

Table Of Contents

Previous topic

hello

Next topic

1 / 2

This Page