开发者

i cant understand the following code

开发者 https://www.devze.com 2022-12-11 17:07 出处:网络
Matrix<开发者_如何学编程;float> trainData2 = trainData.GetRows(intVar >> 1, intVar, 1);
Matrix<开发者_如何学编程;float> trainData2 = trainData.GetRows(intVar >> 1, intVar, 1);

intVar is integer type... please help me to understand this code.


>> 1 means "shift right one" which is a low-level way of saying "divide unsigned by 2".

Maybe that's the clue you needed?


If the part you don't understand is intVar >> 1, this is just shifting the value one bit at the right. In other words, it divides intVar by two.


Well >> 1 is right shift; in this case, it will (effectively) return halve the value of intVar (except for some cases involving -ve numbers). I don't know what your trainData is, but I'm guessing we're building a matrix of half of a table or something?

0

精彩评论

暂无评论...
验证码 换一张
取 消