473,396 Members | 1,774 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.

Re: Question about enum values


So, let's say, like what you said, we have this:

0, 0000, None
1, 0001, CanOpen
2, 0010, CanProcess
3, 0011, CanComplete
8, 1000, CanCancel

or

0, 0000, None
1, 0001, CanOpen
2, 0010, CanProcess
3, 0011, CanComplete
4, 0100, CanCancel

In the first case, CanComplete | CanCancel gives us 1011 and CanOpen |
CanProcess gives us 0011

In the second case, CanComplete | CanCancel gives us 0111, and CanOpen
| CanProcess gives us 0011

Of course, in the second case, None | CanComplete and CanOpen |
CanProcess will give us the same result: 0011
>>You have 3 in your top example and is why it's failing. It's 4, not 3.

Sep 29 '08 #1
4 965
On Sep 29, 12:41*pm, "Jeff Dillon" <jeffdil...@hotmailremove.com>
wrote:
So, let's say, like what you said, we have this:

0, 0000, None
1, 0001, CanOpen
2, 0010, CanProcess
3, 0011, CanComplete
8, 1000, CanCancel

or

0, 0000, None
1, 0001, CanOpen
2, 0010, CanProcess
3, 0011, CanComplete
4, 0100, CanCancel

In the first case, CanComplete | CanCancel gives us 1011 and CanOpen |
CanProcess gives us 0011

In the second case, CanComplete | CanCancel gives us 0111, and CanOpen
| CanProcess gives us 0011

Of course, in the second case, None | CanComplete and CanOpen |
CanProcess will give us the same result: 0011
>You have 3 in your top example and is why it's failing. It's 4, not 3.
Yeah, I know Scott Allen's original (i.e., CanComplete = 4 instead of
3) would work like Jeroen said.

But, Jeroen says:

<quote>
If "CanComplete" was defined as 3, it would look the same as CanOpen |
CanProcess.
</quote>

So, I don't know if he wants CanCancel to be 4 or 8. That's why I had
two cases, 0, 1, 2, 3, 8 and 0, 1, 2, 3, 4. I did not need to test 0,
1, 2, 4, 8, which I know how it works after Jeroen's explanation.

Sep 29 '08 #2
Author wrote:
On Sep 29, 12:41 pm, "Jeff Dillon" <jeffdil...@hotmailremove.com>
wrote:
>So, let's say, like what you said, we have this:

0, 0000, None
1, 0001, CanOpen
2, 0010, CanProcess
3, 0011, CanComplete
8, 1000, CanCancel

or

0, 0000, None
1, 0001, CanOpen
2, 0010, CanProcess
3, 0011, CanComplete
4, 0100, CanCancel

In the first case, CanComplete | CanCancel gives us 1011 and CanOpen |
CanProcess gives us 0011

In the second case, CanComplete | CanCancel gives us 0111, and CanOpen
| CanProcess gives us 0011

Of course, in the second case, None | CanComplete and CanOpen |
CanProcess will give us the same result: 0011
>>You have 3 in your top example and is why it's failing. It's 4, not 3.

Yeah, I know Scott Allen's original (i.e., CanComplete = 4 instead of
3) would work like Jeroen said.

But, Jeroen says:

<quote>
If "CanComplete" was defined as 3, it would look the same as CanOpen |
CanProcess.
</quote>

So, I don't know if he wants CanCancel to be 4 or 8.
I... really don't want it to be anything. Pretend it doesn't exist. It's
orthogonal to my point. If the flags are already incorrect it doesn't matter
how you continue.
That's why I had
two cases, 0, 1, 2, 3, 8 and 0, 1, 2, 3, 4. I did not need to test 0,
1, 2, 4, 8, which I know how it works after Jeroen's explanation.
Yes, let's focus on that and forget the rest. 0, 1, 2, 4, 8 etcetera is the
only correct progression for bitflags.

--
J.
Sep 29 '08 #3
On Sep 29, 12:57*pm, Jeroen Mostert <jmost...@xs4all.nlwrote:
Author wrote:
On Sep 29, 12:41 pm, "Jeff Dillon" <jeffdil...@hotmailremove.com>
wrote:
So, let's say, like what you said, we have this:
0, 0000, None
1, 0001, CanOpen
2, 0010, CanProcess
3, 0011, CanComplete
8, 1000, CanCancel
or
0, 0000, None
1, 0001, CanOpen
2, 0010, CanProcess
3, 0011, CanComplete
4, 0100, CanCancel
In the first case, CanComplete | CanCancel gives us 1011 and CanOpen |
CanProcess gives us 0011
In the second case, CanComplete | CanCancel gives us 0111, and CanOpen
| CanProcess gives us 0011
Of course, in the second case, None | CanComplete and CanOpen |
CanProcess will give us the same result: 0011
>You have 3 in your top example and is why it's failing. It's 4, not 3..
Yeah, I know Scott Allen's original (i.e., CanComplete = 4 instead of
3) would work like Jeroen said.
But, Jeroen says:
<quote>
If "CanComplete" was defined as 3, it would look the same as CanOpen |
CanProcess.
</quote>
So, I don't know if he wants CanCancel to be 4 or 8.

I... really don't want it to be anything. Pretend it doesn't exist. It's
orthogonal to my point. If the flags are already incorrect it doesn't matter
how you continue.
That's why I had
two cases, 0, 1, 2, 3, 8 and 0, 1, 2, 3, 4. *I did not need to test 0,
1, 2, 4, 8, which I know how it works after Jeroen's explanation.

Yes, let's focus on that and forget the rest. 0, 1, 2, 4, 8 etcetera is the
only correct progression for bitflags.

--
J.
I understood, I was only testing how we get

OrderTransitions canCompleteAndCancel = OrderTransitions.CanComplete |
OrderTransitions.CanCancel;

should we assign 0, 1, 2, 3, 4 or 0, 1, 2, 3, 8.

I guess it is my turn to confuse you now. :-)
Sep 29 '08 #4
I... really don't want it to be anything. Pretend it doesn't exist. It's
orthogonal to my point. If the flags are already incorrect it doesn't
matter how you continue.
I would have thought that the underlying vectors being orthogonal was your
point !
Oct 1 '08 #5

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

Similar topics

6
by: James Brown | last post by:
Hi, I have the following enum declared: enum TOKEN { TOK_ID = 1000, TOK_NUMBER, TOK_STRING, /*lots more here*/ }; What I am trying to do is _also_ represent ASCII values 0-127 as TOKENs...
3
by: Richard | last post by:
Okay gang, This should be simple but apparently it's not... I want to use the System.DayOfWeek enum to create and access an array of objects with one object for each day of the week. I'd like...
13
by: Adam Blair | last post by:
Is it possible to bind a switch statement to an Enum such that a compile-time error is raised if not all values within the Enum are handled in the switch statement? I realise you can use default:...
31
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
18
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I have created an enum list like this: enum myEnum : int { This = 2, That, NewVal = 10, LastItm
14
by: Steve | last post by:
Sorry in advance for my ignorance. Any help would sure be appreciated. I'm writing a fairly simple application with VB.Net and am obviously a bit of a newbie. This application will be used by 1,...
37
by: mdh | last post by:
In one of the answers to a K&R exercise, the first couple of lines are: enum loop { NO, YES}; enum loop okloop=YES; I get the first line, but not the second. Sorry about the LOL question. ...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
0
by: Shell | last post by:
Hi, So here's my story. I have an enum that's defined so: public enum AccountKind { Savings = 0, Current = 1, }
6
by: bsma1 | last post by:
I building a web service that has an enum I want the consuming application to be able to use. I have the enum declared in the web service as: public enum myEnum { ONE = 1, TWO = 2, };
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
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
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...
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,...

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.