### Author Topic: Decimal Binary conversion  (Read 2360 times)

0 Members and 1 Guest are viewing this topic.

#### AngelFish

• Is this my custom title?
• LV12 Extreme Poster (Next: 5000)
• Posts: 3242
• Rating: +270/-27
• I'm a Fishbot
##### Decimal Binary conversion
« on: November 10, 2010, 05:50:45 pm »
Does anyone know of an efficient way to convert decimal numbers and store each digit of the output to a separate place?

I'm aware of Weregoose's

Code: [Select]
int(round(BfPart(NB^seq(I,I,‾int(ln(N)/ln(B))-1,‾1
However, typing it into the homescreen returns an Err:Argument.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

#### kindermoumoute

• Posts: 836
• Rating: +54/-3
##### Re: Decimal Binary conversion
« Reply #1 on: November 10, 2010, 06:25:25 pm »
Compatible all bases.

« Last Edit: November 20, 2010, 11:33:21 am by kindermoumoute »
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

#### meishe91

• Super Ninja
• LV11 Super Veteran (Next: 3000)
• Posts: 2946
• Rating: +115/-11
##### Re: Decimal Binary conversion
« Reply #2 on: November 10, 2010, 06:35:34 pm »
Here's the method I wrote to turn decimal to binary quite a while ago. Not sure what I could come up with now though, just to lazy

Code: [Select]
" →Str3Prompt AWhile A≥1iPart(A)/2→AStr3+sub("10",1+not(fPart(Ans)),1→Str3EndFor(X,1,length(Ans)-1sub(Ans,2X,1)+AnsEndsub(Ans,1,X
Should work.

What do you mean though by store each digit in a separate place?

The thing about Weregoose's is that it exports into a list (and I don't remember correctly or not but it might still be reversed too) and lists can be tricky to manipulate.
« Last Edit: November 10, 2010, 06:48:26 pm by meishe91 »
Spoiler For Spoiler:

For the 51st time, that is not my card! (Magic Joke)

#### AngelFish

• Is this my custom title?
• LV12 Extreme Poster (Next: 5000)
• Posts: 3242
• Rating: +270/-27
• I'm a Fishbot
##### Re: Decimal Binary conversion
« Reply #3 on: November 10, 2010, 07:26:11 pm »

What do you mean though by store each digit in a separate place?

The thing about Weregoose's is that it exports into a list (and I don't remember correctly or not but it might still be reversed too) and lists can be tricky to manipulate.

Well, I kind of want it in lists. I need to deal with the individual digits separately and they're going to be exported into a string in a particular order. That means that I'd eventually have to store to lists anyway. Plus, lists make it easy to pad the output, so I can have the fixed list size that I need.
« Last Edit: November 10, 2010, 07:27:47 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

#### meishe91

• Super Ninja
• LV11 Super Veteran (Next: 3000)
• Posts: 2946
• Rating: +115/-11
##### Re: Decimal Binary conversion
« Reply #4 on: November 10, 2010, 07:49:14 pm »
Well what kind of manipulating are you looking at doing? Like specifically. Are you trying to put all the ones at the beginning, at the end, randomize it all just with a set number of each, etc.
Spoiler For Spoiler:

For the 51st time, that is not my card! (Magic Joke)

#### AngelFish

• Is this my custom title?
• LV12 Extreme Poster (Next: 5000)
• Posts: 3242
• Rating: +270/-27
• I'm a Fishbot
##### Re: Decimal Binary conversion
« Reply #5 on: November 10, 2010, 07:53:40 pm »
I'm playing with the formatting of the Save file in Battlefield. It's rather complex, involving a lot of intermixed data. It's a security thing. Can't have people knowing which bits to flip to cheat the game
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

#### Deep Toaster

• So much to do, so much time, so little motivation
• LV13 Extreme Addict (Next: 9001)
• Posts: 8217
• Rating: +758/-15
##### Re: Decimal Binary conversion
« Reply #6 on: November 10, 2010, 07:59:28 pm »
Does anyone know of an efficient way to convert decimal numbers and store each digit of the output to a separate place?

I'm aware of Weregoose's

Code: [Select]
int(round(BfPart(NB^seq(I,I,‾int(ln(N)/ln(B))-1,‾1
However, typing it into the homescreen returns an Err:Argument.

It works for me And I think that's just about the most optimized base converter you can get with BASIC. Are you using the vars correctly (base (2 in this case) in B, your decimal in N)?

#### AngelFish

• Is this my custom title?
• LV12 Extreme Poster (Next: 5000)
• Posts: 3242
• Rating: +270/-27
• I'm a Fishbot
##### Re: Decimal Binary conversion
« Reply #7 on: November 10, 2010, 08:00:49 pm »
Yep. I checked the variables. However, without changing the variables, splitting it up eliminates the error.

The program is working now. Thanks for the help.
« Last Edit: November 10, 2010, 08:03:22 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

#### Deep Toaster

• So much to do, so much time, so little motivation
• LV13 Extreme Addict (Next: 9001)
• Posts: 8217
• Rating: +758/-15
##### Re: Decimal Binary conversion
« Reply #8 on: November 10, 2010, 08:04:08 pm »
Can you make a screenie? It works for me...

Maybe you make some obscure typo?

#### AngelFish

• Is this my custom title?
• LV12 Extreme Poster (Next: 5000)
• Posts: 3242
• Rating: +270/-27
• I'm a Fishbot
##### Re: Decimal Binary conversion
« Reply #9 on: November 10, 2010, 08:12:14 pm »
It's working in Wabbit, but not on my calc itself.

EDIT:  A RAM clear fixes it
« Last Edit: November 10, 2010, 08:12:38 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

#### Deep Toaster

• So much to do, so much time, so little motivation
• LV13 Extreme Addict (Next: 9001)
• Posts: 8217
• Rating: +758/-15
##### Re: Decimal Binary conversion
« Reply #10 on: November 10, 2010, 08:14:04 pm »
Ooh...

Testing any glitchy programs recently?

EDIT: Versailles.
« Last Edit: November 10, 2010, 08:14:35 pm by Deep Thought »

#### AngelFish

• Is this my custom title?