473,503 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inverting Binary Vales

im new to working with binary data, i was wondering if tehr was an easy way
to flip the values ie....f7 becomes 7f....things like that...im using c#.
Jul 21 '05 #1
2 1101
"Thaynann" <Th******@discussions.microsoft.com> wrote in message
news:D2**********************************@microsof t.com...
im new to working with binary data, i was wondering if tehr was an easy
way
to flip the values ie....f7 becomes 7f....things like that...im using c#.


I think System.Net.IPAddress.NetworkToHostOrder will convert from little
endian to big endian and vice-versa.
Jul 21 '05 #2
Thaynann <Th******@discussions.microsoft.com> wrote:
im new to working with binary data, i was wondering if tehr was an easy way
to flip the values ie....f7 becomes 7f....things like that...im using c#.


Sean's mentioned a way of doing some big-endian stuff, and there's also
my EndianBitConverter which allows you to specify which endianness you
want: http://www.pobox.com/~skeet/csharp/miscutil

However, that's not *quite* what you asked for - do you *really* want
to flip nybbles? If so, it's as simple as:

byte flipped = (byte)( (original & 0xf) << 4 |
(original & 0xf0) >> 4);

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3

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

Similar topics

4
5985
by: Paul | last post by:
Hi, (First apologies if this is not the most relevant place to post this but I wasn't sure of where was and I am writing my app in VB.) I'm attempting to parse a binary file for which I have...
13
15194
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the...
20
7523
by: Christian Stigen Larsen | last post by:
A signed int reserves one bit to signify whether a number is positive or negative. In light of this, a colleague asked me whether there existed an int in C++ that was -0, a zero with the negative...
3
3472
by: Tron Thomas | last post by:
What does binary mode for an ofstream object do anyway? Despite which mode the stream uses, operator << writes numeric value as their ASCII representation. I read on the Internet that it is...
9
6498
by: Ching-Lung | last post by:
Hi all, I try to create a tool to check the delta (diff) of 2 binaries and create the delta binary. I use binary formatter (serialization) to create the delta binary. It works fine but the...
1
323
by: spalding | last post by:
One issue I've had is successfully searching for regular expression documentation outlining the approach to inverting the test (ie. returning true in the case that the expression is not found)....
2
281
by: Thaynann | last post by:
im new to working with binary data, i was wondering if tehr was an easy way to flip the values ie....f7 becomes 7f....things like that...im using c#.
10
22583
by: rory | last post by:
I can't seem to append a string to the end of a binary file. I'm using the following code: fstream outFile("test.exe", ios::in | ios::out | ios::binary | ios::ate | ios::app)...
16
4464
by: Erwin Moller | last post by:
Why is a binary file executable? Is any binary file executable? Is only binary file executable? Are all executable files binary? What is the connection between the attribute of binary and that of...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.