Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.
1
| parseInt('08', 10); |
oftewel altijd het getalstelsel meegeven als je decimaal wilt
Intentionally left blank
[ Voor 107% gewijzigd door BtM909 op 23-12-2003 11:25 ]
Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.
Als je bijvoorbeeld 0x10 ingeeft komt hij terug met 16.
Geef maar eens 020 in, komt hij terug met 16. 018 en 019 wordt 1.
Lijkt wel een bugje in de functie te zijn. Waarom geef je het tweede cijfer als je een invalid invoer geeft (028 -> 2, 038 -> 3)?
[ Voor 40% gewijzigd door Maasluip op 23-12-2003 11:26 ]
Signatures zijn voor boomers.
Of nog erger, wordt de parseInt standaard als octaal gezien?mdeen schreef op 23 december 2003 @ 11:24:
Het lijkt erop alsof 08 en 09 als octaal worden gezien (en dan invalid zijn en dus 0 teruggeven)
Als je bijvoorbeeld 0x10 ingeeft komt hij terug met 16.
Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.
Het is een vrij oud gebruik om getallen die met 0 beginnen als octaal te zien.BtM909 schreef op 23 december 2003 @ 11:25:
[...]
Of nog erger, wordt de parseInt standaard als octaal gezien?
Misschien omdat 0 en o op elkaar lijken?
Signatures zijn voor boomers.
If the radix is not specified or is specified as 0, JavaScript assumes the following:
• If the input string begins with "0x", the radix is 16 (hexadecimal).
• If the input string begins with "0", the radix is eight (octal). This feature is deprecated.
• If the input string begins with any other value, the radix is 10 (decimal).
Intentionally left blank
Ofwel: altijd parseInt(value, 10) gebruiken.
Oh, dat zei crisp ook al in zijn eerste post
ps: dit is echt standaard gebruik, 0x als hexadecimaal, 0 als octaal. In C wordt dat ook zo gedaan (en java leunt zwaar op C)
[ Voor 10% gewijzigd door Maasluip op 23-12-2003 11:35 ]
Signatures zijn voor boomers.
Ik snap het al, alleen raar dat 0000000008 ook hexadecimaal wordt aangezien. Anyway: mijn probleem is opgelost... Bedankt allenmdeen schreef op 23 december 2003 @ 11:33:
[...]
Ofwel: altijd parseInt(value, 10) gebruiken.
edit:
Oh, dat zei crisp ook al in zijn eerste post
ps: dit is echt standaard gebruik, 0x als hexadecimaal, 0 als octaal. In C wordt dat ook zo gedaan (en java leunt zwaar op C)
Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.
Nee, octaal. het begint met een 0 dus het is octaal.BtM909 schreef op 23 december 2003 @ 11:38:
[...]
Ik snap het al, alleen raar dat 0000000008 ook hexadecimaal wordt aangezien. Anyway: mijn probleem is opgelost... Bedankt allen
Signatures zijn voor boomers.