|
We're glad you came by, but you might find what you're looking for elsewhere. TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it. Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope. |
Converts a binary (base 2) number to a decimal (base 10) number.
Ans - The binary number that you want to convert expressed as a list, stored in Ans.
Ans - The decimal representation of the binary number.
Ans, A
TI-83/84/+/SE
imcoraline
:sum(seq(Ans(dim(Ans)-A)2^A,A,0,dim(Ans)-1This routine takes a positive whole binary number (base 2), expressed as a list, and converts it to the equivalent decimal (base 10) representation. To express a binary number in a list, you simply put commas in between each digit, and then surround that with list brackets. For example, the binary number 101101 expressed a list would be {1,0,1,1,0,1}. To learn how to convert a binary number to a decimal number, vice versa, and even see how to convert to and from other bases besides binary and decimal, see the Binary and Hexadecimal page.
It also may be important to note that adding 0’s to the front of a binary number will not change the decimal equivalent. For example, both 01101012 and 1101012 are equivalent to 5310.
Error Conditions
- ERR:DATA TYPE is thrown if the list has an imaginary number in it.
- An error will not be thrown the list is not a binary number, or if any element in the list is negative or non-whole. Nonetheless, the conversion will not work correctly.
Related Routines
.