Re: how to specify power of number



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?
.



Relevant Pages

  • Re: Nth request of book recommendations
    ... > sort of topic/request countless times, but I haven't found past threads as ... > another introduction to the language - I've gone through that already. ... not some sort of C encyclopedia. ... Also I'm not sure about its value as a complete reference. ...
    (comp.lang.c)
  • Wrapl website updated.
    ... The Wrapl website http://wrapl.sf.net has finally been updated. ... is now some sort of a tutorial and an almost complete language ... reference. ...
    (comp.lang.misc)
  • Re: how to specify power of number
    ... Well, not silly, but I am surprised that you start a new language ... without consulting some sort of reference. ...
    (comp.lang.c)
  • Re: Wrapl website updated.
    ... is now some sort of a tutorial and an almost complete language ... I would appreciate it if people could download and try to ... Weird things happen to the formatting of the Reference Manual page on ...
    (comp.lang.misc)
  • Re: Question on LSP
    ... not have to be explicit attributes, ... Since objects in memory usually don't move, the language can largely hide the identity mapping. ... My issue here is that whatever semantic meta model the language uses, there must be some way for the developer to unambiguously express the OOA/D is-a semantics for some problem space entity. ... Note that the language allows us to use a name like 'T' on the reference as a mnemonic so that the developer can keep track of what is happening with the indirection. ...
    (comp.object)