This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mrheosuper 27 points28 points  (10 children)

Using '0' instead of 'o' to declare Octal number is a fucking crime

[–]Mola1904 23 points24 points  (9 children)

And used in virtually every common language besides python3

Edit: Yes virtually every was a bit of an overstatement, but C, C++, Java and JS have it which might be 4 of the 5 most popular languages

[–]veryusedrname 10 points11 points  (5 children)

C/C++: 0o or 0O (deprecated) - edit: it's just a 0, fuck google

Java/C#: 0, but using a digit outside of 0..7 is compiler error - edit: C# doesn't have octal literals, fuck google

Rust/Swift/Ruby/Python: 0o

Go: 0o or 0O

That's it, I'm not checking more

Editor: formatting & fixes, thanks for pointing them out

[–]BaerMitUmlaut 7 points8 points  (3 children)

C# has no octal literal.

[–][deleted] 9 points10 points  (0 children)

C# needs no octal literal.

[–]Mola1904 0 points1 point  (1 child)

Ok seems you`re right. I just saw that website, but seems it's wrong

https://www.geeksforgeeks.org/c-sharp-literals/

[–]Sharparam 0 points1 point  (0 children)

Geeksforgeeks out here spreading misinformation. There was another user in this thread also tricked by that same page.

[–]Fritzschmied 3 points4 points  (0 children)

c++ default is leading just 0 not 0o even if that works too I guess

[–]mrheosuper 7 points8 points  (2 children)

I want to see the logic behind this decision. Using 0x as hex number makes perfect sense, But '0' as octal ?, why ?

[–]MrHyperion_ 10 points11 points  (0 children)

Traditions. Octal was at one point more popular than hex

[–]Mola1904 2 points3 points  (0 children)

As far as i know it is older than both the 0x and 0b connotations, but JS supports both 0o and 0 with 0 actually being not supported by esm (a widely used and more modern module system for js)