简体   繁体   English

C++ 到 VB.NET 转换

[英]C++ to VB.NET conversion

I am getting stuck on converting the following C++ lines to VB.NET.我无法将以下 C++ 行转换为 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? VB.NET 转换会是什么样子?

  1. VB.NET supports bitshifting using the same << and >> operators as C and C++. VB.NET 支持使用与 C 和 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.在 VB.NET 中,您不能将赋值放在表达式中,因此您必须单独进行。

     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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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