473,394 Members | 1,902 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,394 software developers and data experts.

Bit-wise operations against UInt vars

How can I do a bit-wise operation on a UInt, such as:

dim x as UInt32

x = x And &H80

It says the "And operator isn't defined for UInt32"

But why not? And is there a work-around?

(yes, I must use unsigned-integers...I'm trying to write routines to convert
between IBM<->IEEE floating point, and I must access the floats as if they're
unsigned integers)

Thanks!

Nov 21 '05 #1
7 1638
"David" <Da***@discussions.microsoft.com> schrieb:
How can I do a bit-wise operation on a UInt, such as:

dim x as UInt32

x = x And &H80

It says the "And operator isn't defined for UInt32"


Unsigned integers are not CLS-compliant and thus not supported by VB.NET.
You can either wait for VB 2005 or write the code in C#.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

"David" <Da***@discussions.microsoft.com> wrote in message
news:20**********************************@microsof t.com...
How can I do a bit-wise operation on a UInt, such as:

dim x as UInt32

x = x And &H80

It says the "And operator isn't defined for UInt32"

But why not? And is there a work-around?

(yes, I must use unsigned-integers...I'm trying to write routines to convert between IBM<->IEEE floating point, and I must access the floats as if they're unsigned integers)

Thanks!


In addition to Herfried's comments...
Writing the method in C# is the "easiest" method in the short term (until VB
2005).
However, having done the same thing for VAX / PDP11 <-> IEEE, I can say from
experience that it can be done with signed Integers. I used primarily byte
arrays, but also a signed Int64 for convenience. Since the top bit of the
float is the sign bit, just store it's value for later use, then clear it.
The rest fits nicely into an Int64, or easily broken down into smaller
Integer types. If all else fails, there is still the byte array.
Another thing that might cause frustration is bit shifting. If you don't
have VB 2003, then I don't think you have native support for the shift
operators. In this case, "I" would at least mix in some C# to make things
easier. If C# isn't your thing, it is still do-able in VB, just less fun.

Gerald
Nov 21 '05 #3
Gerald,

I went ahead a began writing my routine in C# (maybe after VB 2005 is out
I'll rewrite it)...

But I'll be darned if I can get IEEE->IBM to work correctly! I started with
sample code I found at SAS, but after a couple of days staring at it and
trying to port it, I'm beginning to wonder if the sample code really works
(or whether its just user-error).

Do you know of sample code that goes from IBM float to IEEE float? 32 bit
(single precision) would be preferred, but 64 bit would also be OK. And the
language doesn't really matter (although C or similar would be best).

Or if you don't know of code, maybe just the underlying algorithm?

Thanks,

David


"Gerald Hernandez" wrote:
having done the same thing for VAX / PDP11 <-> IEEE


Nov 21 '05 #4

"David" <Da***@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
Gerald,

I went ahead a began writing my routine in C# (maybe after VB 2005 is out
I'll rewrite it)...

But I'll be darned if I can get IEEE->IBM to work correctly! I started with sample code I found at SAS, but after a couple of days staring at it and
trying to port it, I'm beginning to wonder if the sample code really works
(or whether its just user-error).

Do you know of sample code that goes from IBM float to IEEE float? 32 bit
(single precision) would be preferred, but 64 bit would also be OK. And the language doesn't really matter (although C or similar would be best).

Or if you don't know of code, maybe just the underlying algorithm?

Thanks,

David


David,

Which IBM Float specifically are you needing, as there are a couple
different definitions?
I don't recall running across a sample for IBM floats, well, no "good"
example for any float conversions for that matter. I had to mull it over
myself bit-by-bit. So I feel your pain. Bit-Twiddling Floating Point values
is quite an experience. I now have a much greater understanding, respect,
and healthy fear of floats. :-)
Do you know the Byte order?
Since most floating point definitions share the same common concepts, I
suspect it would be possible to alter my VAX<-> IEEE code to work with IBM.
If you can point me to an /exact/ definition of what you are working with, I
can see if this is possible.

Gerald
Nov 21 '05 #5
Hmm... It appears that the IBM format is more different from VAX than I
previousely thought.
Interestingly, the solution is actually easier. I found this which I think
should get you back on track.
http://support.microsoft.com/default...;EN-US;q235856

Gerald
Nov 21 '05 #6
Gerald,

Yes, that KB article is helpful, but it goes in the wrong direction
(IBM-to-IEEE).
I needed IEEE-to-IBM.

Anyway, this morning I had one of those conceptual breakthroughs, and
finally figured-out why the SAS example
(http://support.sas.com/techsup/technote/ts140.html) wasn't working... it was
my error during porting their example to C#.

So I've now got a C# function that does IEEE-to-IBM (in fact, I used the VB
code from the MSDN article to round-trip test my function, and it looks like
it's working OK).

Thanks for the help!

(I might post my function once it's been tested a bit more)

David

"Gerald Hernandez" wrote:
I found this which I think
should get you back on track.
http://support.microsoft.com/default...;EN-US;q235856

Gerald

Nov 21 '05 #7

"David" <Da***@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
Gerald,
<Snip...>
(I might post my function once it's been tested a bit more)

David


Glad you got it worked out. Yeah, posting the function might be a good idea.
As you have found, this can be a painful experience and there isn't a whole
heck of a lot of good examples out there. I read a little bit from the link
you sent and had to laugh when I read the following line:
"Not included is VAX, which uses a different floating point representation
than either IBM mainframe or IEEE."

I think maybe I should generalize my VAX<-> IEEE code and post that as well.
Someone might find it helpful.

Gerald
Nov 21 '05 #8

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

Similar topics

2
by: Skybuck Flying | last post by:
Hi, I think I might have just invented the variable bit cpu :) It works simply like this: Each "data bit" has a "meta data bit". The meta data bit describes if the bit is the ending bit...
13
by: Amy DBA | last post by:
I've been asked to administer a DB2 V 8 (32-bit install) on a Solaris 64-bit platform. It seems like whomever installed DB2 on the server, goofed for not installing DB2 v8 64 bit. Do I understand...
12
by: Jean-Marc Blaise | last post by:
Hi, Is it worth to use 64-bit DB2 instances on a 32-bit kernel, in terms of: - performance - configuration (go beyond the 256 Mb segment for private mem, 1.75 Gb for Bufferpools) - other ? ...
112
by: Carsten Hansen | last post by:
Suppose I'm using an implementation where an int is 16 bits. In the program below, what function is called in the first case, and what is called in the second case? Also, if there is a difference...
11
by: JDeats | last post by:
1. Will there be different 64-bit .NET implementations for Intel and AMD 64-bit processors or will they share a common 64-bit CLR? 2. Will .NET managed code compiled for the 32-bit CLR be binary...
4
by: tommydkat | last post by:
Well, I've finally gotten UDB 8.2 FixPak 3 up and running on my HP-UX 11i system, thanks to Mr McBride and IBM support. :) I created a 32-bit instance and that's running just fine. However, I...
14
by: ern | last post by:
Does a function exist to convert a 128-bit hex number to a string?
14
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I am using C# to develop DLL using Visual Studio 2005 and .Net 2.0, and I have no idea of how to make my DLL work with applications on 64-bit platform. Above all, I do not...
1
by: Chuck Chopp | last post by:
I have some code that is being built on the following: Windows Server 2003, both 32-bit & 64-bit editions Windows Vista, both 32-bit & 64-bit editions Windows Server 2008, both 32-bit & 64-bit...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.