Results 1 to 5 of 5

Thread: Convertion

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Location
    Antwerp
    Posts
    20

    Angry

    Hi,

    I need to convert a decimal value into a binary value, and I don't know how!!

    It is a decimal value from 0 to 255 (8 bit long)

    Then I need every single bit, for putting pixels on my screen. Every bit represents a pixel wich can be black or white. How can I do that????

    TNX

    Viperke
    Viperke

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    Binary=int(Dec/128) & int(Dec/64) mod 2 & int(Dec/32) mod 2 & int(Dec/16) mod 2 & int(Dec/8) mod 2 & int(Dec/4) mod 2 & int(Dec/2) mod 2 & Dec mod 2
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Location
    Antwerp
    Posts
    20

    Cool Convertion dec ->> bin

    TNX kendaman

    I'll try it

    Viperke

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    Public Function Dec2Bin(lNumber As Long) As String
        Dim iLoopCounter As Integer
        If lNumber >= 2 ^ 31 Then
            Dec2Bin = "Too big"
            Exit Function
        End If
        Do
            If (lNumber And 2 ^ iLoopCounter) = 2 ^ iLoopCounter Then
                Dec2Bin = "1" & Dec2Bin
            Else
                Dec2Bin = "0" & Dec2Bin
            End If
            iLoopCounter = iLoopCounter + 1
        Loop Until 2 ^ iLoopCounter > lNumber
    End Function
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Location
    Antwerp
    Posts
    20

    Wink Thanks

    TNX parksie

    I'll also try these code!!

    TNX again..

    Viperke

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width