how to specify power of number
- From: Yanb <Yanb@xxxxxxxxxxxxxxxx>
- Date: Fri, 18 Apr 2008 11:39:21 +0200 (CEST)
Hi, I'm new to c, so please excuse, if this is silly ;-)
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(textip[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
*256, which does look silly ;-) (Just curious, what if I'd ever need to make 100th power of 256 ;-) )
Thank you in advance.
.
- Follow-Ups:
- Re: how to specify power of number
- From: Noob
- Re: how to specify power of number
- From: Bartc
- Re: how to specify power of number
- From: Ben Bacarisse
- Re: how to specify power of number
- Prev by Date: Problem in writing structure to Binary file in C lang
- Next by Date: Re: Sockets
- Previous by thread: Problem in writing structure to Binary file in C lang
- Next by thread: Re: how to specify power of number
- Index(es):
Relevant Pages
|