I have a C++ code that I'm trying to reuse on my C# project and I need some help. Here is the subject
for (int i = 0; i < numOfSamples; i++)
{
*(((double*)m_Buffer) + i)
= max(*(((double*)m_Buffer) + i*4), *(((double*)m_Buffer) + i*4 + 1));
}
where m_Buffer is array of float. This part of code read each 2 "floats" of array as a one "double" and then do some manipulations (shift it, choose max etc.) The question is - how can I do the same operation in C#.
For example, I have an array [12,45,26,32,07,89,14,11] and I have to transform items in position 0 and 1 (12 and 45) so that I will get a new number (type of double) where highest (I'm not sure - maybe lowest) part of bits will be formed from 12 and lowest - from 45
It should be something like:
for (int i = 0; i < numOfSamples; i++)
{
m_Buffer[i] = Math.Max(m_Buffer[i * 4], m_Buffer[i * 4 + 1]);
}
Where m_Buffer must be an array of at least numOfSamples * 4 + 1 elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With