Questions tagged [octal]
3 questions
42
votes
11 answers
Where are octals useful?
I just banged my head against the table for some 20 minutes looking at a totally weird bug in PHP, and then I realized there's octal. The <%(*> octal.
In short, I padded some literals with zeros so the code would be aligned, I know, big mistake.…
Petruza
- 1,058
24
votes
3 answers
Why do so many languages treat numbers starting with 0 as octal?
I've read Where are octals useful? and it seems like octals are something that were once upon a time useful.
Many languages treat numbers preceding with a 0 as octal, so the literal 010 is actually 8. A few among these is JavaScript, Python (2.7),…
Manishearth
- 708
2
votes
2 answers
Which numeral systems are useful in computer science?
I am wondering which numeral system different programmers are using, or would use if their language has support for them. As an example, in C++ we can use:
Octal by prefixing with 0 (e.g. 0377)
Decimal by default (e.g. 255)
Hexadecimal by prefixing…
authchir
- 370