Page 1 of 1
Binary to "255-number-system"
Posted: Mon Sep 22, 2003 6:53 pm
by Trond
Anyone who knows how to convert a binary number to a number in a "255-siffer-system"? (Not in purebasic, just math in general)
Re: Binary to "255-number-system"
Posted: Mon Sep 22, 2003 7:12 pm
by GPI
What is the 255-siffer-system?
Re: Binary to "255-number-system"
Posted: Tue Sep 23, 2003 12:14 am
by Doobrey
GPI wrote:What is the 255-siffer-system?
I think he means cypher ?
Doesn`t make any difference, I`m still confused :roll:
Posted: Tue Sep 23, 2003 10:52 am
by Fred
Try to look to RSA, BlowFish, AES and other encryptions (cyphering) systems..
More concrete
Posted: Tue Sep 23, 2003 6:31 pm
by Trond
binary = 01011001 (2-siffer-system)(0,1)
Decimal = 89 (10-siffer-system)(0,1,2,3,4,5,6,7,8,9)
Hexadecimal = 59 (16-siffer-system)(0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f)
"My system" = ? (255-siffer-system)(0,1....ABC...abc...!.,:...)
Posted: Tue Sep 23, 2003 6:36 pm
by LarsG
Are you trying to list the ASCII table (and in wrong order i must say) !?!
I don't get this 255 number system..

:roll:
-Lars
Posted: Tue Sep 23, 2003 6:40 pm
by Paul
I've always heard these number systems refered to as "Base" systems.
Base 2 is the binary counting... 10101 etc.
Base 10 is what (most) humans use, I guess cause we have 10 fingers.
Base 16 for computers (hexadecimal)
Now Base 255, you would of course have to create your own character set to represent everything since I'm pretty sure there is no standard for it

Posted: Tue Sep 23, 2003 6:41 pm
by GPI
>binary = 01011001 (2-siffer-system)(0,1)
76543210
= 0*2^7+1*2^6+0*2^5+1*2^4+1*2^3+0*2^2+0*2^1+1*2^0
>Decimal = 89 (10-siffer-system)(0,1,2,3,4,5,6,7,8,9)
= 8*10^1+9*10^0
>Hexadecimal = 59 (16-siffer-system)(0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f)
= 5*16^1+9*16^0
"My system" = ? (255-siffer-system)(0,1....ABC...abc...!.,:...)
Code: Select all
DEZIMAL=1123454
base=256
a=DEZIMAL
a$=""
For i=9 To 0 Step -1
b=Pow(base,i)
digit=a/b
a-digit*b
a$+" "+Str(digit)
Next
Debug "dezimal:"+Str(DEZIMAL)
Debug "Base "+Str(base)+":"+a$
Debug 17*256*256+36*256+126
GPI
Posted: Tue Sep 23, 2003 7:19 pm
by GPI
Second edition
Code: Select all
c$="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
DEZIMAL=1123454
base=32;Len(c$)
a=DEZIMAL
a$=""
For i=19 To 0 Step -1
b=Pow(base,i)
If b>0
digit=a/b
a-digit*b
If digit>0 Or a$<>""
If base<=Len(c$)
a$+Mid(c$,digit+1,1)
Else
a$+Str(digit)+" "
EndIf
EndIf
EndIf
Next
Debug "dezimal:"+Str(DEZIMAL)
Debug "Base "+Str(base)+":"+a$
dez=0
If base<=Len(c$)
*adr.Byte=@a$
While *adr\b
dez*base
dez+FindString(c$,Chr(*adr\b),0)-1
*adr+1
Wend
Else
k=1
Repeat
b$=StringField(a$,k," "):k+1
If b$
dez*base
dez+Val(b$)
EndIf
Until b$=""
EndIf
Debug "Re-Dezimal:"+Str(dez)
Base below 37: Use the Alphabet for additonal digits.
above 36: Write "digits" direct, like 123 534 732
Posted: Thu Sep 25, 2003 4:17 pm
by Trond
GPI: Syntax error at line 11 & 12(pow function)
It is essential that i don't write "direct numbers". I am trying to write a binary number as short as possible.
Posted: Thu Sep 25, 2003 5:49 pm
by GPI
No problem here. Maybe again a userlib with a name-conflict...
GPI