See also: hexToDec, octToDec |
Converts a binary number string to a decimal number.
JSV_binToDec(expB)
expB.binToDec()
The binToDec function returns the decimal number of the binary number string.
The binToDec function uses the following arguments.
Argument | Description |
expB | The binary number string that is to be converted to a decimal. |
There is no checking whether expB is a binary string. Users of this function should check that the value of expB is a valid argument to this function.
Uses the parseInt
function to return an integer representing the specified binary string.
If the first character cannot be converted to a number, parseInt
returns
NaN
.
n/a
The following lines of code
var f = "101011";
document.write( "The number " + f + " is decimal " + JSV_binToDec(f) );
f = "1011110110";
document.write( "The number " + f + " is decimal " + JSV_binToDec(f) );
produce
Copyright © 1998-2000 Roaring Fork Software. All rights reserved.