Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
BaseConverter
//JavaScript-C24.2.0 (SpiderMonkey) print(convertFromBase("1000101", 2)); function convertFromBase(num, base) { if (!base || base < 2 || (base > 10 && base !== 16)) { return -1; } let value = 0; for (let i = num.length - 1; i >= 0; i--) { let digit = digitToValue(num[i]); if (digit < 0 || digit > base){ return -1; } let exp = num.length - i - 1; value += digit*Math.pow(base, exp); } return value; } function digitToValue(ch) { return ch; }
run
|
edit
|
history
|
help
0
Nombre en MAYÚSCULAS
House prices
JavaScript - CheckDate()
2-D Kinematics with accurate air drag
Triangle
Alternating Sign Fibonacci
javascript check undefined
Herrn
Star wars ep 3. limit
Change format Numbers