473,231 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

xor question

I have a stream of chars where I am trying to xor certain parts. I guess the
meat of my question is that if I xor the hex values:
476f ^ 7262
I get a different value that if I xor the integer values:
71111 ^ 114098
Does anyone know why? I'm assuming that I can't just use the hex values for
xor in c# or am I wrong? It would make my life much easier if I could.

Thanks,
Susan
Dec 14 '05 #1
3 2000
Susan,

Well, considering that 476F does not equal 71111, but rather 18287, and
7262 in hex equals 29282 (and not 114098), I would say that could be one of
the reasons.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Susan" <Su***@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
I have a stream of chars where I am trying to xor certain parts. I guess
the
meat of my question is that if I xor the hex values:
476f ^ 7262
I get a different value that if I xor the integer values:
71111 ^ 114098
Does anyone know why? I'm assuming that I can't just use the hex values
for
xor in c# or am I wrong? It would make my life much easier if I could.

Thanks,
Susan

Dec 14 '05 #2
KH
The "f" suffix on "476f" specifies a float type - you need to prefix hex
values with "0x" - note that hex values default to an unsigned int or
unsigned long if not assigned to a variable.
"Susan" wrote:
I have a stream of chars where I am trying to xor certain parts. I guess the
meat of my question is that if I xor the hex values:
476f ^ 7262
I get a different value that if I xor the integer values:
71111 ^ 114098
Does anyone know why? I'm assuming that I can't just use the hex values for
xor in c# or am I wrong? It would make my life much easier if I could.

Thanks,
Susan

Dec 14 '05 #3
Susan <Su***@discussions.microsoft.com> wrote:
I have a stream of chars where I am trying to xor certain parts.
Do you mean a stream of bytes? If you genuinely mean a stream of chars,
you shouldn't be xoring things at all - it's a really bad idea to treat
character data as binary data.
I guess the meat of my question is that if I xor the hex values:
476f ^ 7262
I get a different value that if I xor the integer values:
71111 ^ 114098
Does anyone know why? I'm assuming that I can't just use the hex values for
xor in c# or am I wrong? It would make my life much easier if I could.


You don't get a different value - you get a compile time error. You
can't XOR an int with a float.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mohammed Mazid | last post by:
Can anyone please help me on how to move to the next and previous question? Here is a snippet of my code: Private Sub cmdNext_Click() End Sub Private Sub cmdPrevious_Click() showrecord
3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
2
by: Allan Ebdrup | last post by:
Hi, I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix question is a question where you have several options that can all be rated according to several possible ratings (from...
3
by: Zhang Weiwu | last post by:
Hello! I wrote this: ..required-question p:after { content: "*"; } Corresponding HTML: <div class="required-question"><p>Question Text</p><input /></div> <div...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.