473,405 Members | 2,279 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,405 software developers and data experts.

How do I inspect data?

Hello, I am having a problem marshaling data between managed and unmanaged code. So I need to inspect the data at the byte level. What I need to do is store a number, say 8 into a 4-byte integer then copy it to an array bytArray(4) and compare those bytes with other data. I also need to set up the same array and copy it to an integer variable.

Can this be done? And if so does anyone know how?
Feb 19 '10 #1

✓ answered by tlhintoq

The value of 8 wouldn't need to be 4 bytes. One would due just fine so long as you don't need to send a value greater than 255.

The first byte would be the number of 1's - This would be set to 8.
The second byte would be the number of 256's
3rd would be number of 65536's
4th would be number of 16777216's

Anyway... Read up on the BitConverter at MSDN This does what you need.

2 1280
tlhintoq
3,525 Expert 2GB
The value of 8 wouldn't need to be 4 bytes. One would due just fine so long as you don't need to send a value greater than 255.

The first byte would be the number of 1's - This would be set to 8.
The second byte would be the number of 256's
3rd would be number of 65536's
4th would be number of 16777216's

Anyway... Read up on the BitConverter at MSDN This does what you need.
Feb 19 '10 #2
Excellent!! Thank you that is exactly what I needed!!

Just wanted to note you do need 4 bytes if you are storing 8 as a 32 bit integer. And yes that is a waste (waste of memory, but saving of CPU cycles), but if a structure has the member defined as an integer or a function that you did not write returns an integer you have no control over it. Then there's the issue of -8, which I just found out is stored as (248, 255, 255, 255) when typed as an integer

I am having a serious scanner issue and it looks like I have to examine the memory and perhaps manually marshal the data since 8 forums I posted the question to have no clue as to how to solve it (or I can not explain it properly). But with Marshal.ReadInt32 and BitConverter.GetBytes I hope I can figure out what is going wrong.
Feb 19 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Hans Georg Krauthaeuser | last post by:
Dear all, I have a problem to get the command that has called a function if the command was given on multiple lines. E.g.: ################################################### import inspect ...
2
by: Fernando Perez | last post by:
Hi all, IPython has suffered quite a few problems with the inspect module in python 2.3. For these, unfortunately all I've been able to do is guard with overreaching except clauses, as I had...
11
by: It's me | last post by:
I discovered the hardway what inspect.isclass() is doing. Consider this no brainer code: ### import inspect class Abc: def Hello(self): return
5
by: Tim Henderson | last post by:
Hello I want to creat a program that can inspect a set of classes that i have made and spit out a savable version of these classes. To do this I need to be able to inspect each class and get all...
0
by: Ron Adam | last post by:
While playing around with the inspect module I found that the Blockfinder doesn't recognize single line function definitions. Adding the following two lines to it fixes it, but I'm not sure if it...
5
by: Brian Kitt | last post by:
I have a C# application that builds dynamic HTML and renders it. Because it is rendered in this way, the input controls are not server controls. I write the entire page, which has a variable...
0
by: Stef Mientki | last post by:
hello, I'm not familiar with inspect, but I get an error (see below) in getmembers ( wx ) Of course this is bug in wx . But would you also call this a bug in inspect ?
0
by: Gabriel Genellina | last post by:
En Tue, 30 Sep 2008 14:57:55 -0300, Stef Mientki <stef.mientki@gmail.com> escribió: Yes. getmembers works fine; try m=getmembers(wx) and see. It fails when you attemp to print (or pprint)...
8
by: Aaron \Castironpi\ Brady | last post by:
Hello, The 'inspect' module has this method: inspect.getargvalues(frame) It takes a frame and returns the parameters used to call it, including the locals as defined in the frame, as shown....
0
by: rajasankar | last post by:
Hi, I am using Jython based application and trying to use inspect.py in the python files. Here is my code import inspect,os,sys,pprint,imp def handle_stackframe_without_leak(getframe): ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.