# Mailinglist Archive: opensuse (2372 mails)

 < Previous Next >
##### Re: [SLE] c programming function:
strtol is simpler...

Avi

--On Saturday, January 27, 2001 11:27:24 PM -0600 Jerry Kreps <jerrykreps@xxxxxxxxxxx> wrote:

Wanting someone to do your school work for you, heh?
(An old teacher can spot these attempts.!)
Your problem isn't coding, it is understanding base conversion math.

7 6 5 4 3
2 1 0 N = 1*2 + 0*2 + 1*2
+ 0*2 + 1*2 + 1*2 + 1*2 + 1*2 10

7 6 5 4 3
2 1 0 N = h*2 + g*2 + f*2
+ e*2 + d*2 + c*2 + b*2 + a*2 10

See the pattern?
Can you write a loop that indexes from 0 to 7, parses a binary number,
hgfedcba, and sums the terms?
JLK

On Saturday 27 January 2001 21:23, s smith wrote:

> off topic, but since it seems that so many of you guys know
programming, maybe you can help me! (On topic in the way that one
day when I am proficient in c, I may become a kernel hacker....)

Real simple question but I am pretty much a beginner here:
How would I write a function in c be to convert from st input a
binary number to output a base ten number? 10101111 entered would
be output 175 or 1.75 x 10^2. (Or does this function exist, but I
don't know it?)

I know it has to be easy but still been spending about an hour now
with incorrect results.

Thanks

----------------------------------------
Content-Type: text/html; charset="iso-8859-1"; name="Attachment: 1"
Content-Transfer-Encoding: quoted-printable
Content-Description:
----------------------------------------

--
Scientific theories, according to Sir Karl Popper, can be "falsified," or
proven wrong, by experiment. Unscientific theories -Marxist dialectical
history and Freudian psychology were Popper's favorites- are formed in
such a way that they cannot be falsified by data.

--
To unsubscribe send e-mail to suse-linux-e-unsubscribe@xxxxxxxx
For additional commands send e-mail to suse-linux-e-help@xxxxxxxx
Also check the FAQ at http://www.suse.com/support/faq

--
Avi Schwartz Get a Life,
avi@xxxxxxxxxxxxxxxxxxx Get Linux!

 < Previous Next >