Click here to Skip to main content
15,893,487 members
Home / Discussions / C#
   

C#

 
GeneralRe: Converting Texbox.Text to int 32 Pin
djkno33-Dec-02 3:12
djkno33-Dec-02 3:12 
Generalclass diagram Pin
Anonymous3-Dec-02 0:54
Anonymous3-Dec-02 0:54 
GeneralRe: class diagram Pin
Ranjan Banerji3-Dec-02 2:09
Ranjan Banerji3-Dec-02 2:09 
GeneralRe: class diagram Pin
Michael P Butler3-Dec-02 3:30
Michael P Butler3-Dec-02 3:30 
GeneralRe: class diagram Pin
kaschimer3-Dec-02 4:11
kaschimer3-Dec-02 4:11 
GeneralRequest for adv C# tips & tricks Pin
ThaRudeDude2-Dec-02 20:58
ThaRudeDude2-Dec-02 20:58 
GeneralRe: Request for adv C# tips & tricks Pin
SimonS2-Dec-02 21:39
SimonS2-Dec-02 21:39 
GeneralLooping Problem. Pin
Steve McLenithan2-Dec-02 19:59
Steve McLenithan2-Dec-02 19:59 
I have finally found a good use for looping in a small tool I am creating.

maxBits: is defined elsewhere in the code as a maximum integer that cannot be passed.
subs: is also defined elsewhere as an integer that needs to be passed by at least a value of 2.

---------------------------------------
A little more in depth:
IE- (2^x), where "x" is an integer value.
What this is really trying to find is the "x" power of 2's value, that is right after the value of "subs" but that power cannot be higher than "maxBits" and if it is, it is invalid and a message needs to be passed to the user.


Here is my code:
------------------------------------

// newSubs is the value of the "x" power of 2 right after the value of "subs" int newSubs = 0; int n = 0; for (int i = 0; i <= maxBits; i++) {
while (n < subs)
{
newSubs = 2^i;
n = tSubs;
}
}

------------------------------------

It just isn't working and I don’t know why. I have tried many different cominations of looping structures to get the effect I need. With the code given above, the program crashes when a value of 3 is assigned to "subs".

Can anyone help me with the looping structure? I am going insane just thinking about it Wink | ;)

Thanks for the help.
Regards,

********************
* SteveMcLenithan
* <a href="mailto:steve@steve-mac.com">steve@steve-mac.com</a>
* <a href="http://steve-mac.com">http://steve-mac.com</a>
********************
GeneralRe: Looping Problem. Pin
Steve McLenithan2-Dec-02 20:01
Steve McLenithan2-Dec-02 20:01 
GeneralRe: Looping Problem. Pin
Daniel Turini2-Dec-02 22:14
Daniel Turini2-Dec-02 22:14 
GeneralRichTextBox Scrollbar Pin
ragear2-Dec-02 16:30
ragear2-Dec-02 16:30 
GeneralRe: RichTextBox Scrollbar Pin
leppie3-Dec-02 1:17
leppie3-Dec-02 1:17 
GeneralRe: RichTextBox Scrollbar Pin
ragear3-Dec-02 14:55
ragear3-Dec-02 14:55 
GeneralSome Bugs While Running C# Application On Win98 Pin
yccheok2-Dec-02 14:16
yccheok2-Dec-02 14:16 
GeneralRe: Some Bugs While Running C# Application On Win98 Pin
Jeff J3-Dec-02 16:20
Jeff J3-Dec-02 16:20 
GeneralRe: Some Bugs While Running C# Application On Win98 Pin
yccheok3-Dec-02 16:43
yccheok3-Dec-02 16:43 
GeneralRe: Some Bugs While Running C# Application On Win98 Pin
Nick Parker3-Dec-02 16:49
protectorNick Parker3-Dec-02 16:49 
GeneralRe: Some Bugs While Running C# Application On Win98 Pin
James T. Johnson3-Dec-02 16:59
James T. Johnson3-Dec-02 16:59 
GeneralRe: Some Bugs While Running C# Application On Win98 Pin
Nick Parker3-Dec-02 18:17
protectorNick Parker3-Dec-02 18:17 
GeneralRe: Some Bugs While Running C# Application On Win98 Pin
Jeff J3-Dec-02 20:37
Jeff J3-Dec-02 20:37 
GeneralCom interop Pin
grv5752-Dec-02 14:07
grv5752-Dec-02 14:07 
GeneralRe: Com interop Pin
James T. Johnson2-Dec-02 14:16
James T. Johnson2-Dec-02 14:16 
GeneralRe: Com interop Pin
grv5752-Dec-02 15:28
grv5752-Dec-02 15:28 
GeneralRe: Com interop Pin
James T. Johnson2-Dec-02 15:38
James T. Johnson2-Dec-02 15:38 
GeneralRe: Com interop Pin
grv5752-Dec-02 16:14
grv5752-Dec-02 16:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.