简体   繁体   中英

C++ to VB.NET conversion

I am getting stuck on converting the following C++ lines to VB.NET. Most of these appear to involve bit shifting, however, I need to get the << and >> out of the code as well as an equality check:

   nn = n << 1

   m >>= 1

   istep = mmax << 1

   wr=(wtemp=wr)*wpr-wi*wpi+wr;  //what is the check for wtemp=wr?

What would the VB.NET conversions look like?

  1. VB.NET supports bitshifting using the same << and >> operators as C and C++.

     Dim nn As Int32 = n << 1 m = m >> 1 istep = mmax << 1
  2. wr=(wtemp=wr)*wpr-wi*wpi+wr; is not doing any "checking" - it's an inline assignment. In VB.NET you cannot put an assignment inside an expression so you must do it separately.

     wtemp = wr wr = wtemp * wpr - wi * wpi + wr

    I would add parenthesis to keep it readable because not everyone can remember exact operator precedence (like myself):

     wtemp = wr wr = ( wtemp * wpr ) - ( wi * wpi ) + wr

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM