Qbasicnews.com
July 15, 2018, 06:12:36 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: TI-83+ Basic- Decimal/Binary converter  (Read 17262 times)
Skyler
Ancient Guru
****
Posts: 564



« on: March 26, 2007, 10:56:55 PM »

Okay, I'm taking a digital Circuits course, so I figured I'd cook up a TI-BASIC converter, since the function wasn't already built in.

If only it were that easy.

This is what I have so far for the dec to bin part:
Code:

Lbl B
Disp "DECIMAL:"
Input D
For(X,8,0,-1)
If (D-(2^X))>0
Then
O+(10^X)->O    'That's a Store In command, not a minus and a greater than.
D-2^X->D
End                    'For the IF
End                    'For the For loop


My problem is that a decimal 1 comes out as 0, and a decimal 255 comes out as 11111110. So does 256.

What am I doing wrong? Or is this just not possible?
Logged

In the beginning, there is darkness the emptiness of a matrix waiting for the light. Then a single photon flares into existence. Then another. Soon, thousands more. Optronic pathways connect, subroutines emerge from the chaos, and a holographic consciousness is born." -The Doctor
Neo
Na_th_an
*****
Posts: 2150



« Reply #1 on: March 27, 2007, 09:18:09 AM »

Code:
Lbl B
Disp "DECIMAL:"
Input D
0->O
For(X,8,0,-1)
   If (D-(2^X))>=0    '#### <- you forgot the equal sign here
   Then
      O+(10^X)->O
      D-2^X->D
   End                
End
Logged
Skyler
Ancient Guru
****
Posts: 564



« Reply #2 on: March 27, 2007, 09:37:01 AM »

:oops: DUH!!!! Of course!
Now it works. Thanks Neo! Cheesy
Logged

In the beginning, there is darkness the emptiness of a matrix waiting for the light. Then a single photon flares into existence. Then another. Soon, thousands more. Optronic pathways connect, subroutines emerge from the chaos, and a holographic consciousness is born." -The Doctor
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!