Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C help, .0f meaning
#11
Another C/C++ question:

In the code
Code:
line 1: *bitbuffer >>= 1;
        line 2: *bitbuffer+1) >>= 1;
        line 3: *bitbuffer+=2;

Does line 3 translate to *bitbuffer = *bitbuffer + 2? I don't know the first two lines, guessing I would think it means if *bitbuffer is greater than 1 or shifted right?

Thanks,
Reply
#12
1. the value @ bitbuffer is assigned the result of shifting it right one.
2. contains a syntax error (author probably meant to shift right the value @ bitbuffer + 1 but forgot the opening parens.)
3. the value @ bitbuffer is assigned the result of adding 2 to it.

If you're talking about C++, the above assumes those operators have not been overloaded. Careful, some people get ticked when C and C++ are lumped together like that.
stylin:
Reply
#13
thanks for help and very quick response.

I did miscopy line 2 it should have read as follows
Code:
*(bitbuffer+1) >>= 1;

So converting to FB the equalivants would be:

Code:
line 1: *bitbuffer = *bitbuffer SHR 1          ' *bitbuffer >>= 1;
        line 2: *bitbuffer = *(bitbuffer+1) SHR 1  '*(bitbuffer+1) >>= 1;
        line 3: *bitbuffer = *bitbuffer + 2              '*bitbuffer+=2;

Thanks,

p.s. I tend to always say C/C++ but thats because of my ignorance of the real differences besides the main obvious OOP stuff. I need to learn more C++
Reply
#14
nah my friend, fb believe in shortcuts as well ;]


Code:
Line 1: *bitbuffer Shr= 1          ' *bitbuffer >>= 1;
        Line 2: *bitbuffer Shr= 1  '*(bitbuffer+1) >>= 1;
        Line 3: *bitbuffer += 2              '*bitbuffer+=2;
Reply
#15
You should be able to do:

Code:
*bitbuffer shr= 1

*(bitbuffer + 1) shr= 1   '/ or ...
bitbuffer[1] shr= 1

*bitbuffer += 2
stylin:
Reply
#16
Quote:bitbuffer Shr= 1

Amazing, where did you dig that up? I never seen it before.
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#17
Thanks for the help, I didn't know you were able to shortcut SHR I knew about some of the operators but thats cool.
Reply
#18
trial and error ;p
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)