Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API

From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
ddephor44266yOh, fun with number systems...
I remember scripts failing on 01.01.2008 because someone used some numeric constants with 0-prefix for years in the date calculation.
That was fun. -
@irene Because that's how decimal works and nobody in their right mind thinks that you can't put zeroes in front of a number
-
joas18836y0-prefixed octal literal have been deprecated in JavaScript. The syntax error only occurs in strict mode for backwards compability.
-
@irene Not only do decimal numbers work that way, all numbers in positional numeral systems with a zero work exactly like that
-
@irene That's how this sorta number system is defined. 00042 is a completely valid number, exactly like 0.42000 is a valid number
-
@irene Yes. Are you honestly in defense of this retarded ass design flaw? 0c42 is more concise and more consistent
-
@irene What about trailing zeroes for decimals like 0.42000. Surely they're not valid either?
-
joas18836yDid I understand this conversation right?
@12bitfloat thinks that 042 shouldn't be an octal representation in any language but resolve to an integer instead (042 == 42) and octal should be prefixed with other characters than numbers, like 0c42.
@irene thinks that 042 shouldn't be a valid number in any base because same integer shouldn't have multiple representations (042 != 42).
If I understood correctly, I must agree with @irene. -
@joas Not that it shouldn't be. It *is* a valid number. And it shouldn't be interpreted as octal but simply as decimal. Sometimes you want to zeropad numbers e.g. in matrix calculations so it lines up nicely. That's how I discovered this in the first place because my math functions returned the wrong results. 042 is a valid decimal number and there's absolutely no reason you shouldn't be able to use it as an integer literal
Related Rants
Fuck whoever invented octal literals with just a zero prefix. 042 should never not equal 42. How hard is it to have 0x42 for hex, 0b11 for binary and 0c42 for octal
rant
fuck
php
radix
javascript