HighTechTalks DotNet Forums  

A Little C# help please

Dotnet Framework (Compact Framework) microsoft.public.dotnet.framework.compactframework


Discuss A Little C# help please in the Dotnet Framework (Compact Framework) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Harry Simpson
 
Posts: n/a

Default A Little C# help please - 01-02-2008 , 04:55 PM






I've pretty much converted Daniel Moth's AsyncCalcPiCF project to VB.net but
for this one gotcha:

b = b>>1;

converts to

b = Machine.Shift.Right(b,1)

and my compiler burps on the Machine as not be declared.

What could be the CF VB.NET translation?

TIA

Harry




Reply With Quote
  #2  
Old   
 
Posts: n/a

Default Re: A Little C# help please - 01-02-2008 , 05:46 PM






Exactly why do you need to bit shift for threading? My guess is that this
is simply part of his sample for the math, making some power-of-two division
faster than by actual division.

b = b >> 1 is the same as saying b /= 2 (or b = b / 2), just faster (though
the compiler may well optimize / 2 to a shift operation anyway, in which
case they would be identical).


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com



"Harry Simpson" <harry.simpson (AT) phgt (DOT) net> wrote

Quote:
I've pretty much converted Daniel Moth's AsyncCalcPiCF project to VB.net
but for this one gotcha:

b = b>>1;

converts to

b = Machine.Shift.Right(b,1)

and my compiler burps on the Machine as not be declared.

What could be the CF VB.NET translation?

TIA

Harry






Reply With Quote
  #3  
Old   
 
Posts: n/a

Default Re: A Little C# help please - 01-02-2008 , 05:48 PM



I should also point out that the output is an integer, not a float, and the
result is simply truncated, so any decimal portion is tossed (not rounded).


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com




"<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote

Quote:
Exactly why do you need to bit shift for threading? My guess is that
this is simply part of his sample for the math, making some power-of-two
division faster than by actual division.

b = b >> 1 is the same as saying b /= 2 (or b = b / 2), just faster
(though the compiler may well optimize / 2 to a shift operation anyway, in
which case they would be identical).


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com



"Harry Simpson" <harry.simpson (AT) phgt (DOT) net> wrote in message
news:OaxYooYTIHA.5288 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
I've pretty much converted Daniel Moth's AsyncCalcPiCF project to VB.net
but for this one gotcha:

b = b>>1;

converts to

b = Machine.Shift.Right(b,1)

and my compiler burps on the Machine as not be declared.

What could be the CF VB.NET translation?

TIA

Harry








Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.