|
-
Aug 12th, 2000, 03:07 AM
#1
Thread Starter
Junior Member
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
-
Aug 12th, 2000, 06:05 AM
#2
transcendental analytic
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.
-
Aug 12th, 2000, 06:11 AM
#3
Thread Starter
Junior Member
Convertion dec ->> bin
TNX kendaman
I'll try it
Viperke
-
Aug 12th, 2000, 08:26 AM
#4
Monday Morning Lunatic
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
-
Aug 12th, 2000, 09:12 AM
#5
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|