[Tutor] to/from binary to/from integer (i.e.'01010101' =85)
"Jörg Wölke"
lumbricus at gmx.net
Fri Jan 16 19:58:08 EST 2004
Hello!
> I have no idea how that works. A more legible, but
> somewhat more verbose, way to do that would be:
Most straightforward IMVHO opinion is this approach:
loop {
Look wheather the least significant bit is a 1: "number & 1"
Store result as char ( '0' or '1' ) into String.
Shift number to the right: "number >>= 1"
} until number == 0 ( because right shifting fills unsigned ints with 0 )
return String.
> Daniel Ehrenberg
Greetings, J"o!
--
"Wir können alles sehen, was sich bewegt
und wir können alles zerstören, was wir sehen."
-- Richard Perle
+++ GMX - die erste Adresse für Mail, Message, More +++
Bis 31.1.: TopMail + Digicam für nur 29 EUR http://www.gmx.net/topmail
More information about the Tutor
mailing list