Re: how to specify power of number
- From: Yanb <Yanb@xxxxxxxxxxxxxxxx>
- Date: Fri, 18 Apr 2008 15:07:23 +0200 (CEST)
Ben Bacarisse <ben.usenet@xxxxxxxxx> wrote in
news:87od877aoh.fsf@xxxxxxxxx:
Yanb <Yanb@xxxxxxxxxxxxxxxx> writes:
Hi, I'm new to c, so please excuse, if this is silly ;-)
Well, not silly, but I am surprised that you start a new language
without consulting some sort of reference.
Hi, and thank you for reply. I have read some very basics, but usually I need a language for a specific
thing and as soon as I know enough to complete the task, I leave learning till later :-/
Do you have some tip for a newbie where to start? Of course I can google out load of pages about c,
but no search engine can compete with reference from a human ;-)
I made a C function, which takes IP adress from string and converts
to unsigned long int. Everything works, but I found that the
"counting" part part works only with this:
numericip=atoi(textip[0])*256*256*256+atoi(textip[1])*256*256+atoi(tex
tip[2])*256+atoi(textip[3]);
When I wrote *(256^3), I got fake results. I'd like to use something
more sophisticated, instead of 256*256
^ is exclusive or in C. C does not have an exponentiation operator.
Most C programmers would use a shift (<<) by 24, 16 or 8 bits to
compute the value you want.
Oh yes, that's it, thanks, shifting I know shifts from php ;-) This way will need less cpu cycles than
multiplication.
Ok, so there no way to write mathematic "power of" in c?
.
- Follow-Ups:
- Re: how to specify power of number
- From: Jens Thoms Toerring
- Re: how to specify power of number
- References:
- how to specify power of number
- From: Yanb
- Re: how to specify power of number
- From: Ben Bacarisse
- how to specify power of number
- Prev by Date: Re: C++, C#, C Excellent site!!!
- Next by Date: Re: ioctl serial port and SIOCGSTAMP
- Previous by thread: Re: how to specify power of number
- Next by thread: Re: how to specify power of number
- Index(es):
Relevant Pages
|