Binary to "255-number-system"

Everything else that doesn't fall into one of the other PB categories.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Binary to "255-number-system"

Post 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)
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: Binary to "255-number-system"

Post by GPI »

What is the 255-siffer-system?
Doobrey
Enthusiast
Enthusiast
Posts: 218
Joined: Sat Apr 26, 2003 4:47 am
Location: Dullsville..population: me
Contact:

Re: Binary to "255-number-system"

Post 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:
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Try to look to RSA, BlowFish, AES and other encryptions (cyphering) systems..
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

More concrete

Post 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...!.,:...)
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post 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

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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 :)
Image Image
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post 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
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post 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
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

No problem here. Maybe again a userlib with a name-conflict...

GPI
Post Reply