codedamn

Why is 025 === 21 true in many programming languages?

Asked by Sai Siva Kumar about a year ago

1

How and why 025 === 21 is true?

It evalutes true in every programming language, what is the reson behind it.

1 Answer

    1

    Haha interesting question!

    This has to do with the Octal number system! Basically, In many programming languages, an Octal number is represented by preceding with "0", thus the value in Octal can be written as 025 (which is equivalent to 21 in Decimal).

    You can check the conversion result here: https://decimal-to-binary.com/decimal-to-binary-converter-online.html?id=25621

    Fun fact: In modern browsers (JavaScript 1.8.5 / Firefox 4+), undefined is a non-configurable, non-writable property per the ECMAScript 5 specification. But earlier you could overwrite the value of undefined in JS 😂 Probably still possible in IE8

    @mayanksh

    Mayank Sharma

    @mayanksh

Your answer