[algogeeks] Re: hextoint program MS Q

2012-01-15 Thread Gene
Which language? On Jan 15, 8:23 pm, Ashish Goel ashg...@gmail.com wrote: Hi, given a string in hex, convert it into int. Write test cases for the same. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- You received this message because you

Re: [algogeeks] Re: hextoint program MS Q

2012-01-15 Thread Ashish Goel
i would assume C or C++ Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Mon, Jan 16, 2012 at 7:40 AM, Gene gene.ress...@gmail.com wrote: Which language? On Jan 15, 8:23 pm, Ashish Goel ashg...@gmail.com wrote: Hi, given a string in hex,

Re: [algogeeks] Re: hextoint program MS Q

2012-01-15 Thread Ashish Goel
a 0x should come as a negative number Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Mon, Jan 16, 2012 at 8:19 AM, Gene gene.ress...@gmail.com wrote: Okay. Normally you want to use a library that someone else has tested. So:

[algogeeks] Re: hextoint program MS Q

2012-01-15 Thread Gene
And it ought to. Did you try it? On Jan 15, 9:55 pm, Ashish Goel ashg...@gmail.com wrote: a 0x should come as a negative number Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Mon, Jan 16, 2012 at 8:19 AM, Gene

[algogeeks] Re: hextoint program MS Q

2012-01-15 Thread Gene
More detail: For nearly all compilers, int is 32 bits. So I think you mean should return a negative number. I just ran the code, and it does this as expected. To stop parsing prior to overflow, say something like int hex_to_int(char *s) { int i = 0; while (*s) { if ('0' = *s