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

Binary integers

I've obviously got a blind spot for binary arithmetic! Why can't I
say:

Dim x as uint32 = &HFFFFFFFF

(which gives a 'Constant expression not representable' error in
VB2005)

8 characters each of 4 bits should define a 32-bit integer, shouldn't
they? What am I failing to spot/understand?

Is this where integer literals come in - I've seen the term but not a
description?

Dim x as int32 = &HFFFFFFFFI

seems to clear the error though not if it's still declared as a uint.
Is this the recommended way to do what I'm trying to do? (Which is to
define an ARGB colour, but not as a .Net colour type - the third-party
DLL that I need to pass a value to doesn't work directly with .Net
colours.)
Jul 23 '07 #1
2 1268
Use the UI suffix to force an unsigned value (else this is a negative
integer value that can't be used for an unsigned value).

You could also use UInt32.MaxValue...

---
Patrice

"John Dann" <ne**@prodata.co.uka écrit dans le message de news:
eo********************************@4ax.com...
I've obviously got a blind spot for binary arithmetic! Why can't I
say:

Dim x as uint32 = &HFFFFFFFF

(which gives a 'Constant expression not representable' error in
VB2005)

8 characters each of 4 bits should define a 32-bit integer, shouldn't
they? What am I failing to spot/understand?

Is this where integer literals come in - I've seen the term but not a
description?

Dim x as int32 = &HFFFFFFFFI

seems to clear the error though not if it's still declared as a uint.
Is this the recommended way to do what I'm trying to do? (Which is to
define an ARGB colour, but not as a .Net colour type - the third-party
DLL that I need to pass a value to doesn't work directly with .Net
colours.)

Jul 23 '07 #2
"John Dann" <ne**@prodata.co.ukschrieb
I've obviously got a blind spot for binary arithmetic! Why can't I
say:

Dim x as uint32 = &HFFFFFFFF

(which gives a 'Constant expression not representable' error in
VB2005)

In addition to Patrice: The literal at the right is interpreted as an
Integer (not unsigned integer). It's value is -1. -1 can not be stored in an
UInt32. Therefore the exception.
Armin

Jul 23 '07 #3

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

Similar topics

1
by: Johannes | last post by:
Hi, I tried to pack eight integer values and one string into one binary string, which I would like to store in a mysql db. I encountered two problems doing this: 1) $this->packed =...
10
by: J. Campbell | last post by:
OK...I'm in the process of learning C++. In my old (non-portable) programming days, I made use of binary files a lot...not worrying about endian issues. I'm starting to understand why C++ makes...
5
by: rob | last post by:
hey every1, I've got alot of data to write out to file and it's all just 1's and 0's. It's all stored in 2 dimensional arrays of width 32 and varying height. At the moment it's all just...
1
by: rusttree | last post by:
I'm working on a program that manipulates bmp files. I know the offset location of each piece of relevent data within the bmp file. For example, I know the 18th through 21st byte is an integer...
21
by: nephish | last post by:
i have an interesting project at work going on. here is the challenge. i am using the serial module to read data from a serial input. it comes in as a hex. i need to make it a binary and compare it...
8
by: Yeow | last post by:
hello, i was trying to use the fread function on SunOS and ran into some trouble. i made a simple test as follows: i'm trying to read in a binary file (generated from a fortran code) that...
2
by: Chris | last post by:
Hi, What is the most easy way to check on EOF while reading a binary file with all integers ? In lot of examples the read data are first stored in a string, and afterwards the string is...
7
by: John Salerno | last post by:
In C#, writing to a binary file wrote the actual data types into the file (integers, etc.). Is this not how Python binary files work? I tried to write integers into a file, but the write method...
21
by: nicolasg | last post by:
does anyone know a module or something to convert numbers like integer to binary format ? for example I want to convert number 7 to 0111 so I can make some bitwise operations... Thanks
9
by: tguclu | last post by:
Hi I'm trying to make a CRC calculator and for test purposes i'm writing some test routines. I have the pre-calculated crc values for some binary numbers and i want to use them in my code. Is it...
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
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.