Blogged by Ujihisa. Standard methods of programming and thoughts including Clojure, Vim, LLVM, Haskell, Ruby and Mathematics written by a Japanese programmer. github/ujihisa

Wednesday, May 9, 2012

Octal or not Octal

A number literal with begins with 0 differs between programming languages. For example, a programming language considers 015 as 13, or as 15 just by ignoring the first 0, or even throws an error.

I categorized some programming languages by the view.

  • 015 == 13
    • Clojure
    • Scala
    • Java
    • Ruby
    • C
    • Vim script
    • JavaScript
  • 015 == 15
    • Haskell
    • Scheme
    • Emacs Lisp
    • Lua
    • Common Lisp
  • Exception
    • Python
    • CoffeeScript

2 comments:

  1. python 2.7.1 considers 015 as 13:
    >>> 015 == 13
    True

    ReplyDelete
  2. oh I didn't check in 2.7 family. thanks!

    ReplyDelete

Followers