A[i]<<3*i

why is it needed to convert from base 8 to base 10??

On Sun, Aug 21, 2011 at 4:07 PM, Sanjay Rajpal <[email protected]> wrote:

> Hi your intention was logical OR or BITWISE OR ?
>
> u did Logical.
> Sanju
> :)
>
>
>
> On Sun, Aug 21, 2011 at 3:30 AM, sarvesh saran <[email protected]
> > wrote:
>
>> Hi Nitin,
>>
>> thanks that makes sense. I will try that out.
>>
>> I have another question. Is there a  really fast way of converting a
>> hexadecimal string say "02F9A" to its decimal representation in C++?
>>
>> thanks,
>> Sarvesh
>>
>> thanks,
>> Sarvesh
>>
>>
>> On Sun, Aug 21, 2011 at 3:41 PM, Nitin Nizhawan <[email protected]
>> > wrote:
>>
>>> int num = 0;
>>> for(int i=0;i<A.size();i++){
>>>    num=num||(A[i]<<3*i);
>>> }
>>> printf("%d",num);
>>>
>>> I think this will do. Given the number is with in the range of integer.
>>>
>>>
>>> On Sun, Aug 21, 2011 at 3:40 PM, Nitin Nizhawan <
>>> [email protected]> wrote:
>>>
>>>> int num = 0;
>>>> for(int i=0;i<A.size();i++){
>>>>    num=num||(A[i]<3*i);
>>>> }
>>>> printf("%d",num);
>>>>
>>>> I think this will do.
>>>>
>>>>
>>>> On Sun, Aug 21, 2011 at 2:25 PM, sarvesh saran <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I have a vector<int> A or an array (for C guys) that contains the octal
>>>>> representation of a number.
>>>>>
>>>>> So the array can be something like: [1,5,7] or [7,7,5,6,3,4,2] etc
>>>>>
>>>>> i.e no number in the array can be >= 8.
>>>>>
>>>>> Now given this array, I need to convert it its decimal representation.
>>>>>
>>>>> The naive way to do it would be to scan array from left to right, take
>>>>> each digit, multiply by 8 pow (x) where x is from 0 to ...n and compute 
>>>>> sum.
>>>>>
>>>>> i.e something like:
>>>>>
>>>>> int oct = 1;
>>>>> int num = 0;
>>>>>
>>>>>  for(<array length>){
>>>>>         num+= oct * A[i];
>>>>>         oct = oct * 8;
>>>>>     }
>>>>>
>>>>> is there a faster way to do this? maybe using some STL container or 
>>>>> algorithm. ?
>>>>>
>>>>> thanks,
>>>>> sarvesh
>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected].
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to