← Back to list

You know what ??

If a compiler gives an output of `9` for the input `011`, it’s likely interpreting `011` as an octal (base 8) number rather than a decimal…

No name Kuch nhi · 2025-02-20 06:48 · 0 claps · 0.4 min read
#cpp #cpp-programming #compilers #octal #output
Open on Medium ↗
Wiki topics: 💻 · Programming

You know what ?? If you input any number starting with zero in compiler , it will results as octal number…

If a compiler gives an output of 9 for the input 011, it’s likely interpreting 011 as an octal (base 8) number rather than a decimal (base 10) number.

Explanation:

  • In many programming languages (like C, C++, and JavaScript), a number that starts with 0 is interpreted as octal.
  • The octal number system (base 8) uses digits from 0 to 7, meaning 011 in octal needs to be converted to decimal. ie 18¹ + 18⁰ = 9

Would you like more clarification?


메타데이터
post_id
ace5c09deb8e
slug
you-know-what-ace5c09deb8e
url
https://medium.com/@kuchnhinoname/you-know-what-ace5c09deb8e
canonical_url
https://medium.com/@kuchnhinoname/you-know-what-ace5c09deb8e
author_url
https://medium.com/@kuchnhinoname
status
ok
fetched_at
2026-07-20 22:19:23