Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Logic AND between some strings

Reply
Thread Tools

Logic AND between some strings

 
 
Paul
Guest
Posts: n/a
 
      03-09-2011

"Paul" <(E-Mail Removed)> wrote in message
news:E0Qdp.27837$(E-Mail Removed)2...
>
> "Pete Becker" <(E-Mail Removed)> wrote in message
> news:2011030910065089745-pete@versatilecodingcom...
>> On 2011-03-08 20:34:00 -0500, Paul said:
>>
>>> "Pete Becker" <(E-Mail Removed)> wrote in message
>>> news:2011030818103862137-pete@versatilecodingcom...
>>>> On 2011-03-08 16:46:37 -0500, Paul said:
>>>>
>>>>> "Pete Becker" <(E-Mail Removed)> wrote in message
>>>>> news:2011030808444315377-pete@versatilecodingcom...
>>>>>> On 2011-03-07 17:48:08 -0500, James Kanze said:
>>>>>>
>>>>>>> On Mar 7, 10:03 pm, Pete Becker <(E-Mail Removed)> wrote:
>>>>>>>> On 2011-03-07 16:53:50 -0500, crea said:
>>>>>>>
>>>>>>> [...]
>>>>>>>
>>>>>>>> No, it just needs to a text string that represents the integer
>>>>>>>> value in
>>>>>>>> binary. Read about strtoul.
>>>>>>>
>>>>>>> And one that will output the integer value in binary as well.
>>>>>>> That's a little harder.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> Urk. strtoul goes the wrong way, of course.
>>>>>>
>>>>> #include <iostream>
>>>>>
>>>>> const int STR_LEN=8;
>>>>> typedef char bin_str[STR_LEN];
>>>>>
>>>>> int main()
>>>>> {
>>>>> bin_str str1 = "1100110";
>>>>> bin_str str2 = "1000011";
>>>>> bin_str str3 = "0000000";
>>>>>
>>>>>
>>>>> for(int x=0; x<STR_LEN; x++){
>>>>> if(str1[x]=='1' && str1[x]==str2[x])
>>>>> str3[x]=str1[x];
>>>>> }
>>>>>
>>>>> std::cout<< str3;
>>>>>
>>>>> }
>>>>
>>>> Shrug. The discussion was about doing this with integer values. It's
>>>> already been stated several times that doing it character by character
>>>> is better.
>>>>
>>> No it might actually be more efficient doing it with integer values ,
>>> example:

>>
>> Since you've snipped all relevant context, there is no meaningful way to
>> reply to your irrelevant example.
>>
>>>
>>> const int STR_LEN=8;
>>> typedef unsigned char bin_str[STR_LEN];
>>>
>>> int main()
>>> {
>>> bin_str str1 = "1100110";
>>> bin_str str2 = "1000011";
>>> bin_str str3 = "0000000";
>>>
>>> for(int i=0; i<STR_LEN; i++){
>>> str3[i] = str1[i]& str2[i];
>>> }
>>> }
>>>
>>>
>>> The best solution might be to overload the operator& in a specific
>>> string class.

>>
>> Sure. But that's not what this subthread was about, so please stop
>> pretending that you've had some insight that's actually useful.
>>

> I didn't snip anything.


And I wasn't pretending to have any insight to something usefull , I was
showing you lot how to properly do what you all seemed to be bickering
about.



 
Reply With Quote
 
 
 
 
Paul
Guest
Posts: n/a
 
      03-09-2011

"Pete Becker" <(E-Mail Removed)> wrote in message
news:2011030916064156456-pete@versatilecodingcom...
> On 2011-03-09 15:02:14 -0500, Paul said:
>
>> "Paul" <(E-Mail Removed)> wrote in message
>> news:E0Qdp.27837$(E-Mail Removed)2...
>>>
>>> "Pete Becker" <(E-Mail Removed)> wrote in message
>>> news:2011030910065089745-pete@versatilecodingcom...
>>>> On 2011-03-08 20:34:00 -0500, Paul said:
>>>>
>>>>> "Pete Becker" <(E-Mail Removed)> wrote in message
>>>>> news:2011030818103862137-pete@versatilecodingcom...
>>>>>> On 2011-03-08 16:46:37 -0500, Paul said:
>>>>>>
>>>>>>> "Pete Becker" <(E-Mail Removed)> wrote in message
>>>>>>> news:2011030808444315377-pete@versatilecodingcom...
>>>>>>>> On 2011-03-07 17:48:08 -0500, James Kanze said:
>>>>>>>>
>>>>>>>>> On Mar 7, 10:03 pm, Pete Becker <(E-Mail Removed)> wrote:
>>>>>>>>>> On 2011-03-07 16:53:50 -0500, crea said:
>>>>>>>>>
>>>>>>>>> [...]
>>>>>>>>>
>>>>>>>>>> No, it just needs to a text string that represents the integer
>>>>>>>>>> value in
>>>>>>>>>> binary. Read about strtoul.
>>>>>>>>>
>>>>>>>>> And one that will output the integer value in binary as well.
>>>>>>>>> That's a little harder.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> Urk. strtoul goes the wrong way, of course.
>>>>>>>>
>>>>>>> #include <iostream>
>>>>>>>
>>>>>>> const int STR_LEN=8;
>>>>>>> typedef char bin_str[STR_LEN];
>>>>>>>
>>>>>>> int main()
>>>>>>> {
>>>>>>> bin_str str1 = "1100110";
>>>>>>> bin_str str2 = "1000011";
>>>>>>> bin_str str3 = "0000000";
>>>>>>>
>>>>>>>
>>>>>>> for(int x=0; x<STR_LEN; x++){
>>>>>>> if(str1[x]=='1' && str1[x]==str2[x])
>>>>>>> str3[x]=str1[x];
>>>>>>> }
>>>>>>>
>>>>>>> std::cout<< str3;
>>>>>>>
>>>>>>> }
>>>>>>
>>>>>> Shrug. The discussion was about doing this with integer values. It's
>>>>>> already been stated several times that doing it character by
>>>>>> character is better.
>>>>>>
>>>>> No it might actually be more efficient doing it with integer values ,
>>>>> example:
>>>>
>>>> Since you've snipped all relevant context, there is no meaningful way
>>>> to reply to your irrelevant example.
>>>>
>>>>>
>>>>> const int STR_LEN=8;
>>>>> typedef unsigned char bin_str[STR_LEN];
>>>>>
>>>>> int main()
>>>>> {
>>>>> bin_str str1 = "1100110";
>>>>> bin_str str2 = "1000011";
>>>>> bin_str str3 = "0000000";
>>>>>
>>>>> for(int i=0; i<STR_LEN; i++){
>>>>> str3[i] = str1[i]& str2[i];
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>> The best solution might be to overload the operator& in a specific
>>>>> string class.
>>>>
>>>> Sure. But that's not what this subthread was about, so please stop
>>>> pretending that you've had some insight that's actually useful.
>>>>
>>> I didn't snip anything.

>>
>> And I wasn't pretending to have any insight to something usefull , I was
>> showing you lot how to properly do what you all seemed to be bickering
>> about.
>>

>
> Um, you've rather missed the point. Once again: that's not what this
> subthread was about. It was a discussion of how to make the integral
> approach work, not of how best to solve the original question. So, as I've
> said several times, your response is irrelevant. And there's no
> "bickering" here, just some attempts to make code that works.
>

But I showed how to make the integral approach work, how is it irrellevant?




 
Reply With Quote
 
 
 
 
Paul
Guest
Posts: n/a
 
      03-09-2011

"Pete Becker" <(E-Mail Removed)> wrote in message
news:201103091847435970-pete@versatilecodingcom...
> On 2011-03-09 18:22:57 -0500, Paul said:
>
>> "Pete Becker" <(E-Mail Removed)> wrote in message
>> news:2011030916064156456-pete@versatilecodingcom...
>>> On 2011-03-09 15:02:14 -0500, Paul said:
>>>
>>>> "Paul" <(E-Mail Removed)> wrote in message
>>>> news:E0Qdp.27837$(E-Mail Removed)2...
>>>>>
>>>>> "Pete Becker" <(E-Mail Removed)> wrote in message
>>>>> news:2011030910065089745-pete@versatilecodingcom...
>>>>>> On 2011-03-08 20:34:00 -0500, Paul said:
>>>>>>
>>>>>>> "Pete Becker" <(E-Mail Removed)> wrote in message
>>>>>>> news:2011030818103862137-pete@versatilecodingcom...
>>>>>>>> On 2011-03-08 16:46:37 -0500, Paul said:
>>>>>>>>
>>>>>>>>> "Pete Becker" <(E-Mail Removed)> wrote in message
>>>>>>>>> news:2011030808444315377-pete@versatilecodingcom...
>>>>>>>>>> On 2011-03-07 17:48:08 -0500, James Kanze said:
>>>>>>>>>>
>>>>>>>>>>> On Mar 7, 10:03 pm, Pete Becker <(E-Mail Removed)>
>>>>>>>>>>> wrote:
>>>>>>>>>>>> On 2011-03-07 16:53:50 -0500, crea said:
>>>>>>>>>>>
>>>>>>>>>>> [...]
>>>>>>>>>>>
>>>>>>>>>>>> No, it just needs to a text string that represents the integer
>>>>>>>>>>>> value in
>>>>>>>>>>>> binary. Read about strtoul.
>>>>>>>>>>>
>>>>>>>>>>> And one that will output the integer value in binary as well.
>>>>>>>>>>> That's a little harder.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Urk. strtoul goes the wrong way, of course.
>>>>>>>>>>
>>>>>>>>> #include <iostream>
>>>>>>>>>
>>>>>>>>> const int STR_LEN=8;
>>>>>>>>> typedef char bin_str[STR_LEN];
>>>>>>>>>
>>>>>>>>> int main()
>>>>>>>>> {
>>>>>>>>> bin_str str1 = "1100110";
>>>>>>>>> bin_str str2 = "1000011";
>>>>>>>>> bin_str str3 = "0000000";
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> for(int x=0; x<STR_LEN; x++){
>>>>>>>>> if(str1[x]=='1' && str1[x]==str2[x])
>>>>>>>>> str3[x]=str1[x];
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> std::cout<< str3;
>>>>>>>>>
>>>>>>>>> }
>>>>>>>>
>>>>>>>> Shrug. The discussion was about doing this with integer values.
>>>>>>>> It's already been stated several times that doing it character by
>>>>>>>> character is better.
>>>>>>>>
>>>>>>> No it might actually be more efficient doing it with integer values
>>>>>>> , example:
>>>>>>
>>>>>> Since you've snipped all relevant context, there is no meaningful way
>>>>>> to reply to your irrelevant example.
>>>>>>
>>>>>>>
>>>>>>> const int STR_LEN=8;
>>>>>>> typedef unsigned char bin_str[STR_LEN];
>>>>>>>
>>>>>>> int main()
>>>>>>> {
>>>>>>> bin_str str1 = "1100110";
>>>>>>> bin_str str2 = "1000011";
>>>>>>> bin_str str3 = "0000000";
>>>>>>>
>>>>>>> for(int i=0; i<STR_LEN; i++){
>>>>>>> str3[i] = str1[i]& str2[i];
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> The best solution might be to overload the operator& in a specific
>>>>>>> string class.
>>>>>>
>>>>>> Sure. But that's not what this subthread was about, so please stop
>>>>>> pretending that you've had some insight that's actually useful.
>>>>>>
>>>>> I didn't snip anything.
>>>>
>>>> And I wasn't pretending to have any insight to something usefull , I
>>>> was showing you lot how to properly do what you all seemed to be
>>>> bickering about.
>>>>
>>>
>>> Um, you've rather missed the point. Once again: that's not what this
>>> subthread was about. It was a discussion of how to make the integral
>>> approach work, not of how best to solve the original question. So, as
>>> I've said several times, your response is irrelevant. And there's no
>>> "bickering" here, just some attempts to make code that works.
>>>

>> But I showed how to make the integral approach work, how is it
>> irrellevant?

>
> Um, because that's not what you did? The integral approach was converting
> the text to integral values, doing the logical operation on the values,
> and converting the result back to text. Your solution operates directly on
> the characters in the text strings; as I've said several times, that
> approach is clearly preferable. But it's not the approach under discussion
> in this subthread.
>
> --

Also note it is possible to further otpimise as explained here:
http://bmagic.sourceforge.net/bmsse2opt.html


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python Logic Map/Logic Flow Chart. (Example Provided) spike Python 8 02-09-2010 12:31 PM
Asynchronous Logic Gates and Analog Logic Gates Jyoti Ballabh Software 3 11-26-2009 06:48 PM
Relationship between GUI and logic? John Salerno Python 11 05-24-2008 06:22 PM
Want overview for customizing some of the forms authentication logic brianjadams@gmail.com ASP .Net 0 08-02-2006 05:45 PM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM



Advertisments