By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,479 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,479 IT Pros & Developers. It's quick & easy.

Binary integers

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.